diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 12b687c3b..fde312f44 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -393,6 +393,11 @@ class TestImageFont(PillowTestCase): # Assert self.assert_image_equal(im, target_img) + def test_getsize_empty(self): + font = self.get_font() + # should not crash. + self.assertEqual((0, 0), font.getsize('')) + def _test_fake_loading_font(self, path_to_fake, fontname): # Make a copy of FreeTypeFont so we can patch the original free_type_font = copy.deepcopy(ImageFont.FreeTypeFont) diff --git a/_imagingft.c b/_imagingft.c index cd17758e4..3eb8bc0b7 100644 --- a/_imagingft.c +++ b/_imagingft.c @@ -109,7 +109,7 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw) unsigned char* font_bytes; int font_bytes_size = 0; static char* kwlist[] = { - "filename", "size", "index", "encoding", "font_bytes", + "filename", "size", "index", "encoding", "font_bytes", "layout_engine", NULL }; @@ -449,8 +449,6 @@ font_getsize(FontObject* self, PyObject* args) y_max = y_min = 0; count = text_layout(string, self, dir, features, &glyph_info, 0); - if (count == 0) - return NULL; for (x = i = 0; i < count; i++) { int index, error;