Skip to content

Improve text rendering - #9909

Open
akx wants to merge 17 commits into
python-pillow:mainfrom
akx:ft-next
Open

Improve text rendering#9909
akx wants to merge 17 commits into
python-pillow:mainfrom
akx:ft-next

Conversation

@akx

@akx akx commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Note

Stacked on #9908 (I guess GitHub's merge stacks don't work cross-fork, ah well).
That PR ought to be reviewed and merged first and I'll happily rebase this.
24a6fa0 is the first new commit here.

Refs #9898 (not "fixes", since I can't be sure this ends up fixing OP's issues).

What's moving?

Some infrastructure:

  • PILLOW_TEST_SNAPSHOTS can now be set to create, overwrite or update, so assert_image_similar_tofile and assert_image_equal_tofile can update the golden image to what was passed in; this is similar to --snapshot-update for Syrupy or INSTA_UPDATE for Rust's Insta.
  • A test based on Kerning woes #9898's example code, golden snapshots updated as they improve over the patches.

These are the actual fixes; see #9908 for notes on the clean-ups:

  • Passing in a bytestring where some characters had the high bit set would render mojibake/tofu/.NOTDEF (whatever you want to call it) when using the basic renderer. Very corner-case, but also the fix is just a proper (unsigned char) cast.
  • Fractional variable font axis values were truncated; no more!
  • When using basic font layout (which is the case for the default font added in Added TrueType default font to allow for different sizes #7354), advance values were 64× off due to type confusion (see Document and clarify _imagingft #9908's description). No more!
  • Finally (the last 2 commits), glyph positioning within a single call is now subpixel and not pixel-snap-hinted (when available), leading to more accurate rendering.

@akx
akx force-pushed the ft-next branch 3 times, most recently from 14524dc to c2981e6 Compare August 27, 2026 06:37
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.

1 participant