Repository navigation
book: x/image's opentype face kerns by the same pixels at every size - #742
Merged
Merged
Conversation
A known upstream bug in a module go-graphviz pins and nobody here has forked. opentype's (*Face).Kern hands sfnt.Font.Kern the font's units per em where it wants the face's pixels per em, so a pair's kern comes back as the font's units read as 26.6 pixels, the same at every size. Reproduced on Arial at 72 dpi: -2.375 px at 7, 14 and 140 points, where sfnt.Font.Kern at the real pixels per em gives -0.52, -1.05 and -10.39. The line is the same at the module's latest release, which is the head of its repository. go-graphviz, the one repository that imports the package, gives its face a Kern of its own; the entry names it and says when it can go. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: closer-claudio <claudio@farcloser.world>
closer-claudio
enabled auto-merge
November 23, 2026 07:29
Contributor
Author
|
Reviewed at ec2cdde |
apostasie
approved these changes
Nov 23, 2026
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.
🎯 Why
golang.org/x/image'sopentype.Facemoves a kerned pair by the same number of pixels at every size: itsKernhandssfnt.Font.Kernthe font's units per em where that function wants the face's pixels per em. Text measured or drawn through such a face is too tight at small sizes and too loose at large ones. The module is pinned and not forked, so the bug belongs in the book's known upstream bugs, with the workaround one repository carries and the condition under which it goes.🛠️ What
book/upstream.md(L1040-L1066): symptom, cause, workaround, and when it lifts.Kernfor its face, in Kerning grows with the font size: a kerned label is laid out and drawn at one width forkcloser/go-graphviz#258. The entry links that pull request's head commit, which keeps its sha when it merges.🧪 How
(*Face).Kernpassesfixed.Int26_6(f.f.UnitsPerEm()); every other call of the face passes its scale.Face.Kern('A','V')is -2.3750 px at 7, 14 and 140 points;sfnt.Font.Kernat the face's real pixels per em gives -0.5156, -1.0469 and -10.3906.font/opentype.just lintexit 0,just testexit 0,just do security linksexit 0 (549 links, 437 ok, 112 excluded),just do lint commitsexit 0.📝 Notes
main.