Skip to content

LibGfx+LibWeb: Follow fontconfig hinting when rasterizing glyphs - #10579

Merged
awesomekling merged 1 commit into
LadybirdBrowser:masterfrom
tcl3:libweb_font_hinting_fix
Jul 10, 2026
Merged

LibGfx+LibWeb: Follow fontconfig hinting when rasterizing glyphs#10579
awesomekling merged 1 commit into
LadybirdBrowser:masterfrom
tcl3:libweb_font_hinting_fix

Conversation

@tcl3

@tcl3 tcl3 commented Jul 10, 2026

Copy link
Copy Markdown
Member

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:

image

After:

image

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 😞

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.
@awesomekling
awesomekling merged commit e531e7c into LadybirdBrowser:master Jul 10, 2026
13 checks passed
@tcl3
tcl3 deleted the libweb_font_hinting_fix branch July 10, 2026 13:39
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.

Kerning for "Roboto" is broken badly

2 participants