Skip to content

Commit

Permalink
use empty .notdef for sparse TTF masters
Browse files Browse the repository at this point in the history
previously we were copying one from the default master, but if this contains cubic curves our own check fails because the .notdef we inserted in the sparse masters OutlineCompiler was not passed through cu2qu...
Our intention is to have sparse masters not participate in the interpolation of that particular glyph so we make it empty (gid0=.notdef still needs to be there in a valid TTF so we must have one).
Currently the same trick does not work for CFF2 variable fonts (fonttools/fonttools#3233) but those are fine with cubics in .notdef glyph any way.. For now at least
  • Loading branch information
anthrotype committed Aug 1, 2023
1 parent e390805 commit 8d676d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Lib/ufo2ft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def compileInterpolatableTTFsFromDS(designSpaceDoc, **kwargs):
kwargs["skipExportGlyphs"] = designSpaceDoc.lib.get("public.skipExportGlyphs", [])

if kwargs["notdefGlyph"] is None:
kwargs["notdefGlyph"] = _getDefaultNotdefGlyph(designSpaceDoc)
kwargs["notdefGlyph"] = _getDefaultNotdefGlyph(designSpaceDoc, empty=True)

kwargs["extraSubstitutions"] = defaultdict(set)
for rule in designSpaceDoc.rules:
Expand Down
14 changes: 13 additions & 1 deletion Lib/ufo2ft/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def getDefaultMasterFont(designSpaceDoc):
return defaultSource.font


def _getDefaultNotdefGlyph(designSpaceDoc):
def _getDefaultNotdefGlyph(designSpaceDoc, empty=False):
from ufo2ft.errors import InvalidDesignSpaceData

try:
Expand All @@ -488,6 +488,18 @@ def _getDefaultNotdefGlyph(designSpaceDoc):
notdefGlyph = baseUfo[".notdef"]
except KeyError:
notdefGlyph = None
else:
if empty:
# create a new empty .notdef glyph with the same width/height
# as the default master's .notdef glyph to be use for sparse layer
# master TTFs, so that it won't participate in gvar interpolation
# TODO(anthrotype): Use sentinel values for width/height to
# mark the glyph as non-participating for HVAR if/when fonttools
# supports that, https://github.com/googlefonts/ufo2ft/issues/501
emptyGlyph = _getNewGlyphFactory(notdefGlyph)(".notdef")
emptyGlyph.width = notdefGlyph.width
emptyGlyph.height = notdefGlyph.height
notdefGlyph = emptyGlyph
return notdefGlyph


Expand Down

0 comments on commit 8d676d9

Please sign in to comment.