Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Tests/images/bitmap_font_stroke_basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tests/images/bitmap_font_stroke_raqm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions Tests/test_imagefont.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,22 @@ def test_bitmap_font(self, bpp):

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)
Expand Down
2 changes: 1 addition & 1 deletion src/_imagingft.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down