Skip to content

Commit

Permalink
Only use outside border of stroke
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 18, 2025
1 parent a92a664 commit a528dc7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Tests/test_imagedraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,28 @@ def test_stroke_descender() -> None:
assert_image_similar_tofile(im, "Tests/images/imagedraw_stroke_descender.png", 6.76)


@skip_unless_feature("freetype2")
def test_stroke_inside_gap() -> None:
# Arrange
im = Image.new("RGB", (120, 130))
draw = ImageDraw.Draw(im)
font = ImageFont.truetype("Tests/fonts/FreeMono.ttf", 120)

# Act
draw.text((12, 12), "i", "#f00", font, stroke_width=20)

# Assert
for y in range(im.height):
glyph = ""
for x in range(im.width):
if im.getpixel((x, y)) == (0, 0, 0):
if glyph == "started":
glyph = "ended"
else:
assert glyph != "ended", "Gap inside stroked glyph"
glyph = "started"


@skip_unless_feature("freetype2")
def test_split_word() -> None:
# Arrange
Expand Down
2 changes: 1 addition & 1 deletion src/_imagingft.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ font_render(FontObject *self, PyObject *args) {
if (stroker != NULL) {
error = FT_Get_Glyph(glyph_slot, &glyph);
if (!error) {
error = FT_Glyph_Stroke(&glyph, stroker, 1);
error = FT_Glyph_StrokeBorder(&glyph, stroker, 0, 1);
}
if (!error) {
FT_Vector origin = {0, 0};
Expand Down

0 comments on commit a528dc7

Please sign in to comment.