Fix left-side bearing for variable fonts#27
Merged
Merged
Conversation
Collaborator
|
I think you just need to set this to true, and then rerun. |
Member
Author
|
For Cantarell ( Meanwhile, for Noto Sans Regular ( |
LaurenzV
approved these changes
Jun 3, 2026
Collaborator
LaurenzV
left a comment
There was a problem hiding this comment.
To be honest I don't really have the context on the whole xmin/lsb thing anymore, but since it makes PDFs work and also matches fonttools I think this should be the right thing to do!
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.
When interjecting with skrifa, we now derive the LSB from the resulting bounding box rather than from the font's metrics, because the latter does not always agree with the
xMinof the fresh outline we've generated. The OpenType spec heavily advises xMin and LSB to match (it actually requires it for variable fonts or whenhead.flagsbit 1 is set).If
LSB != xMin, glyphs get repositioned by PDF readers (including hayro) and the kerning gets very wonky. In hayro, this happens because skrifa appears to shift the entire outline based on the delta between LSB and xMin. ttf-parser doesn't seem to care about LSB at all...Previously, there was the following comment:
I updated the test references, but I'm not sure how to validate whether the output now matches fonttools...
In any case, here's an example of a before/after when integrated into Typst (with Mona Sans VF).
As for the implementation, I've rewired things a bit to avoid having to recompute the bounding box in
horizontal_metrics. I'm not super happy with the fact that thecustom_hmtxaccumulation relies onsubset_withbeing called in the correct order, but at the same time I tried to keep the fix minimally invasive. I'm open to suggestions.