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

need only build glyf (or CFF) + hmtx for sparse layer masters #308

Closed
anthrotype opened this issue Jan 13, 2019 · 1 comment
Closed

need only build glyf (or CFF) + hmtx for sparse layer masters #308

anthrotype opened this issue Jan 13, 2019 · 1 comment
Assignees

Comments

@anthrotype
Copy link
Member

currently, when designspace source descriptors have a layerName attribute, the ufo2ft.compileInterpolatable... functions will build a whole master font for them, including global such as hhea, OS/2, name, etc. which do not vary from the default UFO masters. This means varLib will attempt to use these to build, e.g., an MVAR.
These "sparse" or intermediate masters only differ from their associated "whole" master UFO for the layer, in which only glyph outlines and metrics are stored. Thus, ufo2ft should only build hmtx and glyf (or CFF) for these intermediate masters.

@anthrotype anthrotype self-assigned this Jan 13, 2019
anthrotype added a commit to anthrotype/fonttools that referenced this issue Jan 14, 2019
when no horizontal/vertical header table is present, we assume numberOfHMetrics == maxp.numGlyphs.
This allows to compile/decompile incomplete fonts, only containing head, maxp, hmtx, loca and glyf (or CFF),
that is the bare minimum to temporarily store glyph outline and metrics data for use with sparse/intermediate
master TTFs in varLib.
See googlefonts/ufo2ft#308
@anthrotype
Copy link
Member Author

anthrotype commented Jan 14, 2019

There is one problem though.
When building sparse masters for TrueType, we store the glyph names in the post table, so that varLib can later on pick glyphs with the same name across multiple masters and blend them together in a variable font.
However, we do not want that the post.underlinePosition and post.underlineThickness values from these sparse masters be used to compute deltas for the MVAR table; those values will be equal to the UFO master in which that sparse layer happens to be located, and that's certainly not the intention of the user to add intermediate masters for underline position/thickness as sideeffect of having intermediate masters for particular glyphs...

I chatted with @behdad and I suggested to use an unlikely magic number for post.underline{Position,Thickness}, both defined as FWord or int16 fields, that signals varLib that the values from that master are not meant to be used for generating the respective MVAR fields. I suggested the value 0x7FFF (or 36767 in decimal, which is the maximum value for a 16-bit signed integer), which would be almost impossible in real world, as it means that if these were real, the top of the underline would be positioned 36767 font units above the baseline, and the thickness would similarly be ridiculously big.
Behdad replied

I'm comfortable with the 0x8000 hack. Just document somewhere how the sparse masters should look like

(I had initially suggested 0x8000 or -36768, but I think 0x7FFF is even less likely than the latter)

I'm still a bit reluctant to add that hack, but I don't see other solutions really, if one wants to be able to read post glyph names from a sparse TTF master, while at the same time ignoring the post underline values for MVAR.

anthrotype added a commit to anthrotype/ufo2ft that referenced this issue Jan 14, 2019
Fixes googlefonts#308

The OutlineCompiler classes gets a tables keyword argument that allows to
customize the list of tables to be built.
For the interpolatable sparse masters (those built from non-default layer)
we only build (head, maxp, hmtx, loca, glyf, and post) for TTF, and
(head, maxp, CFF and hmtx) for CFF-OTF.
anthrotype added a commit to anthrotype/ufo2ft that referenced this issue Jan 14, 2019
Fixes googlefonts#308

The OutlineCompiler classes gets a tables keyword argument that allows to
customize the list of tables to be built.
For the interpolatable sparse masters (those built from non-default layer)
we only build (head, maxp, hmtx, loca, glyf, and post) for TTF, and
(head, maxp, CFF and hmtx) for CFF-OTF.
anthrotype added a commit to anthrotype/ufo2ft that referenced this issue Jan 16, 2019
Fixes googlefonts#308

The OutlineCompiler classes gets a tables keyword argument that allows to
customize the list of tables to be built.
For the interpolatable sparse masters (those built from non-default layer)
we only build (head, maxp, {h,v}mtx, loca, glyf, and post) for TTF, and
(head, maxp, CFF, {h,v}mtx and VORG) for CFF-OTF.

NOTE that varLib still doesn't support vmtx or VORG, but we output them
anyway.
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

No branches or pull requests

1 participant