Skip to content

Commit 19f4c6f

Browse files
committed
don't use bitmap glyphs when drawing text with stroker
1 parent b34430b commit 19f4c6f

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed
2.61 KB
Loading
2.59 KB
Loading

Tests/test_imagefont.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,22 @@ def test_bitmap_font(self, bpp):
867867

868868
assert_image_equal_tofile(im, target)
869869

870+
def test_bitmap_font_stroke(self):
871+
text = "Bitmap Font"
872+
layout_name = ["basic", "raqm"][self.LAYOUT_ENGINE]
873+
target = f"Tests/images/bitmap_font_stroke_{layout_name}.png"
874+
font = ImageFont.truetype(
875+
"Tests/fonts/DejaVuSans/DejaVuSans-24-8-stripped.ttf",
876+
24,
877+
layout_engine=self.LAYOUT_ENGINE,
878+
)
879+
880+
im = Image.new("RGB", (160, 35), "white")
881+
draw = ImageDraw.Draw(im)
882+
draw.text((2, 2), text, "black", font, stroke_width=2, stroke_fill="red")
883+
884+
assert_image_similar_tofile(im, target, 0.03)
885+
870886
def test_standard_embedded_color(self):
871887
txt = "Hello World!"
872888
ttf = ImageFont.truetype(FONT_PATH, 40, layout_engine=self.LAYOUT_ENGINE)

src/_imagingft.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ font_render(FontObject *self, PyObject *args) {
833833
}
834834

835835
im = (Imaging)id;
836-
load_flags = FT_LOAD_DEFAULT;
836+
load_flags = stroke_width ? FT_LOAD_NO_BITMAP : FT_LOAD_DEFAULT;
837837
if (mask) {
838838
load_flags |= FT_LOAD_TARGET_MONO;
839839
}

0 commit comments

Comments
 (0)