mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merge pull request #2624 from radarhere/getsize_emptystring
Added fix for font getsize on empty string
This commit is contained in:
commit
c58dd9bcb3
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user