diff --git a/Tests/images/bitmap_font_stroke_basic.png b/Tests/images/bitmap_font_stroke_basic.png new file mode 100644 index 000000000..86b2d09f6 Binary files /dev/null and b/Tests/images/bitmap_font_stroke_basic.png differ diff --git a/Tests/images/bitmap_font_stroke_raqm.png b/Tests/images/bitmap_font_stroke_raqm.png new file mode 100644 index 000000000..08029ce34 Binary files /dev/null and b/Tests/images/bitmap_font_stroke_raqm.png differ diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 002641faa..6f7646cb0 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -867,6 +867,22 @@ class TestImageFont: assert_image_equal_tofile(im, target) + def test_bitmap_font_stroke(self): + text = "Bitmap Font" + layout_name = ["basic", "raqm"][self.LAYOUT_ENGINE] + target = f"Tests/images/bitmap_font_stroke_{layout_name}.png" + font = ImageFont.truetype( + "Tests/fonts/DejaVuSans/DejaVuSans-24-8-stripped.ttf", + 24, + layout_engine=self.LAYOUT_ENGINE, + ) + + im = Image.new("RGB", (160, 35), "white") + draw = ImageDraw.Draw(im) + draw.text((2, 2), text, "black", font, stroke_width=2, stroke_fill="red") + + assert_image_similar_tofile(im, target, 0.03) + def test_standard_embedded_color(self): txt = "Hello World!" ttf = ImageFont.truetype(FONT_PATH, 40, layout_engine=self.LAYOUT_ENGINE) diff --git a/src/_imagingft.c b/src/_imagingft.c index 2427bc685..bbfca187e 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -833,7 +833,7 @@ font_render(FontObject *self, PyObject *args) { } im = (Imaging)id; - load_flags = FT_LOAD_DEFAULT; + load_flags = stroke_width ? FT_LOAD_NO_BITMAP : FT_LOAD_DEFAULT; if (mask) { load_flags |= FT_LOAD_TARGET_MONO; }