Skip to content

fix(text): single source of truth for glyph advances (#479) - #480

Merged
kolkov merged 5 commits into
mainfrom
fix/advance-single-source
Aug 6, 2026
Merged

fix(text): single source of truth for glyph advances (#479)#480
kolkov merged 5 commits into
mainfrom
fix/advance-single-source

Conversation

@kolkov

@kolkov kolkov commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Unified advanceResolver for Advance(), Glyphs(), AppendGlyphs()
  • Priority: TT hinted > HVAR > raw hmtx (Skia/Chrome pattern)
  • Prevents cursor drift on wide Cyrillic glyphs with TT hinting

Enterprise research

Skia, FreeType, Chrome all enforce: measurement == rendering advances.

Fixes #479

kolkov added 5 commits August 6, 2026 13:31
TestADR054_ShearVariableFont_BoldVsRegular failed locally with GPU
CoverageFiller (SparseStrips) because at 40px, AA fringe pixels
dominate glyph body — pixel count comparison inverts for bold vs regular.

Root cause: SparseStrips (4×4 tiles) and AnalyticFiller (scanline) produce
different sub-pixel coverage at small sizes. NOT a gvar bug — variations
applied correctly (verified via TextPath coordinate comparison).

Fix: increase to 80px where glyph body dominates over AA fringe.
Both rasterizers now produce bold > regular consistently.
Introduce advanceResolver — unified advance resolution used by Advance(),
Glyphs(), and AppendGlyphs(). Priority: TT hinted > HVAR > raw hmtx.
This matches drawGlyphs' hintedOrRawAdvance() ensuring MeasureString
and DrawString agree on character positions (Skia/Chrome pattern).

Enterprise research: Skia, FreeType, Chrome all enforce measurement ==
rendering advances from a single source controlled by hinting level.

Fixes #479
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.37209% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
text/face.go 88.37% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@kolkov
kolkov merged commit e170382 into main Aug 6, 2026
11 checks passed
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.

fix(text): MeasureText returns raw unhinted advances, drawGlyphs uses hinted — cursor drift on wide glyphs

1 participant