Skip to content

Commit

Permalink
glue_together must rebuild glyphID map after adding glyphs to glyf
Browse files Browse the repository at this point in the history
Otherwise we hit fonttools/fonttools#2605
  • Loading branch information
anthrotype committed Apr 29, 2022
1 parent ca02334 commit 1d4f01e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/nanoemoji/glue_together.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def _copy_colr(target: ttLib.TTFont, donor: ttLib.TTFont):
target["CPAL"] = donor["CPAL"]
target["COLR"] = donor["COLR"]

# Adding new glyphs to glyf table automatically appends to the TTFont's
# glyphOrder list, however the cached map from names to glyph IDs is not
# updated, so TTFont.getGlyphID will return incorrect result until
# we force it to be rebuilt, e.g. like so:
# https://github.com/fonttools/fonttools/issues/2605
target.getReverseGlyphMap(rebuild=True)


def _svg_glyphs(font: ttLib.TTFont) -> Iterable[Tuple[int, str]]:
for _, min_gid, max_gid in font["SVG "].docList:
Expand Down

0 comments on commit 1d4f01e

Please sign in to comment.