[varLib.interpolatable] Close over component glyphs

...when processing variable font.

Continuation of 636295a7ee558c5712a719c632a91d6c65bfc6d8

Part of fixing https://github.com/fonttools/fontbakery/discussions/4301
This commit is contained in:
Behdad Esfahbod 2023-10-12 20:45:23 -04:00
parent 89b6b95ba9
commit ca11333bab

View File

@ -376,6 +376,15 @@ def test(glyphsets, glyphs=None, names=None, ignore_missing=False):
return problems
def recursivelyAddGlyph(glyphname, glyphset, ttGlyphSet, glyf):
if glyphname in glyphset:
return
glyphset[glyphname] = ttGlyphSet[glyphname]
for component in getattr(glyf[glyphname], "components", []):
recursivelyAddGlyph(component.glyphName, glyphset, ttGlyphSet, glyf)
def main(args=None):
"""Test for interpolatability issues between fonts"""
import argparse
@ -443,6 +452,7 @@ def main(args=None):
if "gvar" in font:
# Is variable font
gvar = font["gvar"]
glyf = font["glyf"]
# Gather all glyphs at their "master" locations
ttGlyphSets = {}
glyphsets = defaultdict(dict)
@ -463,9 +473,9 @@ def main(args=None):
location=locDict, normalized=True
)
glyphsets[locTuple][glyphname] = ttGlyphSets[locTuple][
glyphname
]
recursivelyAddGlyph(
glyphname, glyphsets[locTuple], ttGlyphSets[locTuple], glyf
)
names = ["()"]
fonts = [font.getGlyphSet()]