Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use outside border of stroke in text() #8701

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

radarhere
Copy link
Member

Resolves #8697

The issue finds that when Pillow draws normal text onto stroked text, there might be an unexpected gap between the the outside of the normal text and the inside border of the stroked text.

main

When drawing stroked text, FreeType returns a glyph with an outside border and an inside border. We can ask FreeType to leave out the inside border though, creating a filled glyph. With that change, the output is corrected.

branch

See https://freetype.org/freetype2/docs/reference/ft2-glyph_stroker.html#ft_glyph_stroke and https://freetype.org/freetype2/docs/reference/ft2-glyph_stroker.html#ft_glyph_strokeborder for documentation.

@radarhere radarhere force-pushed the stroke_outside branch 2 times, most recently from eb0f060 to bc4788e Compare January 18, 2025 09:12
@apodtele
Copy link

apodtele commented Jan 21, 2025

Using only outside border is a good solution in this case.. You might try faster FT_Outline_EmboldenXY but it does not have round joints.

The algorithms are rather complicated. I suspect the problem with the inside border arises when the stroker radius exceeds the stem width or the dot radius. The inside border is ill-defined in this case. I doubt this can be fixed. This could happen to the outside border too but much less frequently.

@radarhere
Copy link
Member Author

Thanks very much for your input.

@hugovk hugovk merged commit b03f143 into python-pillow:main Jan 31, 2025
54 checks passed
@radarhere radarhere deleted the stroke_outside branch January 31, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stroke Text Tittles Not Working Correctly
3 participants