From c69353acb3ffb768cac9d7076d249f544ec28425 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Mon, 22 Apr 2024 22:03:24 +0200 Subject: [PATCH] Find defaultGlyph via model --- src/fontra_compile/builder.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/fontra_compile/builder.py b/src/fontra_compile/builder.py index 1a702a5..7ca1d85 100644 --- a/src/fontra_compile/builder.py +++ b/src/fontra_compile/builder.py @@ -203,12 +203,10 @@ async def prepareOneGlyph(self, glyphName: str) -> GlyphInfo: glyphSources = filterActiveSources(glyph.sources) - sourceCoordinates, locations, defaultGlyph = prepareSourceCoordinates( + sourceCoordinates, locations = prepareSourceCoordinates( glyph, glyphSources, defaultLocation, axisDict ) - assert defaultGlyph is not None - locations = [mapDictKeys(s, axisTags) for s in locations] model = ( @@ -219,11 +217,13 @@ async def prepareOneGlyph(self, glyphName: str) -> GlyphInfo: prepareGvarVariations(sourceCoordinates, model) if model is not None else [] ) + defaultSourceIndex = model.reverseMapping[0] if model is not None else 0 + defaultGlyph = glyph.layers[glyphSources[defaultSourceIndex].layerName].glyph + ttGlyphPen = TTGlyphPointPen(None) defaultGlyph.path.drawPoints(ttGlyphPen) ttGlyph = ttGlyphPen.glyph() - defaultSourceIndex = model.reverseMapping[0] componentInfo = await self.collectComponentInfo(glyph, defaultSourceIndex) return GlyphInfo( @@ -498,7 +498,6 @@ def prepareSourceCoordinates( ): sourceCoordinates = [] locations = [] - defaultGlyph = None firstSourcePath = None for sourceIndex, source in enumerate(glyphSources): @@ -506,10 +505,6 @@ def prepareSourceCoordinates( locations.append(normalizeLocation(location, axisDict)) sourceGlyph = glyph.layers[source.layerName].glyph - if location == defaultLocation: - # This is the fefault glyph - defaultGlyph = sourceGlyph - coordinates = GlyphCoordinates() assert isinstance(sourceGlyph.path, PackedPath) @@ -528,7 +523,7 @@ def prepareSourceCoordinates( coordinates.append((0, 0)) sourceCoordinates.append(coordinates) - return sourceCoordinates, locations, defaultGlyph + return sourceCoordinates, locations def prepareGvarVariations(sourceCoordinates, model):