LibGfx+LibWeb: Follow fontconfig hinting when rasterizing glyphs - #10579
Merged
awesomekling merged 1 commit intoJul 10, 2026
Conversation
Glyph positions and advances are produced by HarfBuzz from un-hinted font metrics, but glyphs were rasterized with Skia's default normal hinting. For fonts without a TrueType hinting program, this makes FreeType's autohinter grid-fit glyph outlines horizontally, so the rasterized glyphs no longer line up with the un-hinted advances. The result is visibly uneven spacing, most noticeably a spurious gap before narrow glyphs such as "t". Resolve the hinting configuration from fontconfig per font family and size, honoring family and size-specific configuration rules such as the common rules that disable hinting for DejaVu fonts at small sizes. The query runs the configuration's substitution edits over a pattern describing the font, standing in for a matched font. Results are cached per font. The configuration itself is loaded before the renderer sandbox is installed, and the queries perform no filesystem access, so resolution at rasterization time is sandbox-safe. Test mode pins the hinting style to normal, matching Skia's previous default, so that rendering is deterministic across machines rather than depending on the host's fontconfig configuration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Glyph positions and advances are produced by HarfBuzz from un-hinted font metrics, but glyphs were rasterized with Skia's default normal hinting. For fonts without a TrueType hinting program, this makes FreeType's autohinter grid-fit glyph outlines horizontally, so the rasterized glyphs no longer line up with the un-hinted advances. The result is visibly uneven spacing, most noticeably a spurious gap before narrow glyphs such as "t".
Resolve the hinting configuration from fontconfig per font family and size, honoring family and size-specific configuration rules such as the common rules that disable hinting for DejaVu fonts at small sizes. The query runs the configuration's substitution edits over a pattern describing the font, standing in for a matched font. Results are cached per font. The configuration itself is loaded before the renderer sandbox is installed, and the queries perform no filesystem
access, so resolution at rasterization time is sandbox-safe.
Test mode pins the hinting style to normal, matching Skia's previous default, so that rendering is deterministic across machines rather than depending on the host's fontconfig configuration.
Tested by visually comparing this test page:
Before:
After:
Fixes #10344
NB: This will conflict with #10547, which removes the direct fontconfig dependency and goes through Skia. Unfortunately, skia doesn't have the necessary APIs for this, so the direct fontconfig dependency would need to be kept 😞