Fixed stroke on FreeType < 2.9

This commit is contained in:
Andrew Murray 2020-02-16 20:40:23 +11:00
parent 80994bc0e5
commit 17c10b0ca0
3 changed files with 21 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -944,6 +944,22 @@ def test_stroke():
)
@skip_unless_feature("freetype2")
def test_stroke_descender():
# Arrange
im = Image.new("RGB", (120, 130))
draw = ImageDraw.Draw(im)
font = ImageFont.truetype("Tests/fonts/FreeMono.ttf", 120)
# Act
draw.text((10, 0), "y", "#f00", font, stroke_width=2, stroke_fill="#0f0")
# Assert
assert_image_similar(
im, Image.open("Tests/images/imagedraw_stroke_descender.png"), 6.76
)
@skip_unless_feature("freetype2")
def test_stroke_multiline():
# Arrange

View File

@ -782,9 +782,6 @@ font_render(FontObject* self, PyObject* args)
im = (Imaging) id;
/* Note: bitmap fonts within ttf fonts do not work, see #891/pr#960 */
load_flags = FT_LOAD_NO_BITMAP;
if (stroker == NULL) {
load_flags |= FT_LOAD_RENDER;
}
if (mask) {
load_flags |= FT_LOAD_TARGET_MONO;
}
@ -792,7 +789,7 @@ font_render(FontObject* self, PyObject* args)
ascender = 0;
for (i = 0; i < count; i++) {
index = glyph_info[i].index;
error = FT_Load_Glyph(self->face, index, load_flags);
error = FT_Load_Glyph(self->face, index, load_flags | FT_LOAD_RENDER);
if (error) {
return geterror(error);
}
@ -806,6 +803,10 @@ font_render(FontObject* self, PyObject* args)
ascender = temp;
}
if (stroker == NULL) {
load_flags |= FT_LOAD_RENDER;
}
x = y = 0;
horizontal_dir = dir && strcmp(dir, "ttb") == 0 ? 0 : 1;
for (i = 0; i < count; i++) {