Skip to content

Commit

Permalink
Find defaultGlyph via model
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Apr 22, 2024
1 parent b4a7d7d commit c69353a
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/fontra_compile/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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(
Expand Down Expand Up @@ -498,18 +498,13 @@ def prepareSourceCoordinates(
):
sourceCoordinates = []
locations = []
defaultGlyph = None
firstSourcePath = None

for sourceIndex, source in enumerate(glyphSources):
location = {**defaultLocation, **source.location}
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)
Expand All @@ -528,7 +523,7 @@ def prepareSourceCoordinates(
coordinates.append((0, 0))
sourceCoordinates.append(coordinates)

return sourceCoordinates, locations, defaultGlyph
return sourceCoordinates, locations


def prepareGvarVariations(sourceCoordinates, model):
Expand Down

0 comments on commit c69353a

Please sign in to comment.