Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

varLib: use sentinel to mark glyph metrics as sparse #3235

Merged
merged 3 commits into from Aug 2, 2023

Conversation

anthrotype
Copy link
Member

@anthrotype anthrotype commented Aug 2, 2023

as discussed in googlefonts/ufo2ft#501, sometimes one wants to have a gyph in a non-default sparse master without it participating in HVAR/VVAR. For outlines (both glyf and CFF) we allow empty glyphs in non-default masters to mean the same as missing, thus non participating. This PR enables a similar thing for hmtx and vmtx advances and sidebearings (we don't actually build deltas for lsb/tsb the sentinel value includes both to make it less likely that it occurs in real world fonts).

With this PR, if a glyph has an advance of 65535 (0xFFFF), it is ignored when building HVAR or VVAR, as if is were missing from a master.

font sources only allow to specify advances, the sidebearings are computed. Makes more sense for the sparse metrics to have 0 for the sidebearings as the glyph that's meant to be 'sparse' is most likely empty with no outlines
@anthrotype
Copy link
Member Author

actually, since UFO doesn't let one specify the sidebearings directly (they are computed from the outlines), it's best to use (0xFFFF, 0) as sentinel, with the sidebearings being 0, which is what an empty glyph would normally get.

@justvanrossum
Copy link
Collaborator

actually, since UFO doesn't let one specify the sidebearings directly (they are computed from the outlines), it's best to use (0xFFFF, 0) as sentinel, with the sidebearings being 0, which is what an empty glyph would normally get.

Hm, I was assuming this would be a hack between ufo2ft and fonttools, for the intermediate otf/ttf master files only, and not be visible at the UFO level: the glyph would simply not exist there.

@anthrotype
Copy link
Member Author

what if you want to have a composite glyph where you variate the component offsets without it participating in the HVAR/VVAR? you could add the base component glyphs as empty glyphs (availing yourself of the rule that non-default empty glyphs are assumed to be missing/non-participating), but you would be forced to have some non-empty hmtx

@anthrotype
Copy link
Member Author

I think I just contradicted myself.. that glyph would not be empty and as such it would get some non-zero lsb

@behdad
Copy link
Member

behdad commented Aug 2, 2023

LGTM!!!

Now do it for kerning :D.

@anthrotype anthrotype merged commit 764cc79 into main Aug 2, 2023
10 checks passed
@anthrotype anthrotype deleted the varlib-sparse-vhmtx branch August 2, 2023 15:46
anthrotype added a commit to googlefonts/ufo2ft that referenced this pull request Aug 2, 2023
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.

None yet

3 participants