Skip to content

Commit

Permalink
Cache base info
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Aug 17, 2023
1 parent e630e39 commit febf239
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/fontra_compile/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async def setup(self):
self.defaultLocation = {k: v[1] for k, v in self.globalAxisDict.items()}

self.cachedSourceGlyphs = {}
self.cachedComponentBaseInfo = {}

self.glyphs = {}
self.cmap = {}
Expand Down Expand Up @@ -231,7 +232,7 @@ async def collectComponentInfo(self, glyph):
attrName: [] for attrName in VAR_COMPONENT_TRANSFORM_MAPPING
},
location={axisName: [] for axisName in axisNames},
**await self.setupComponentBaseInfo(compo.name),
**await self.getComponentBaseInfo(compo.name),
)
for compo, axisNames in zip(
firstSourceGlyph.components, allComponentAxisNames
Expand Down Expand Up @@ -297,6 +298,13 @@ async def collectComponentInfo(self, glyph):

return components

async def getComponentBaseInfo(self, baseGlyphName):
baseInfo = self.cachedComponentBaseInfo.get(baseGlyphName)
if baseInfo is None:
baseInfo = await self.setupComponentBaseInfo(baseGlyphName)
self.cachedComponentBaseInfo[baseGlyphName] = baseInfo
return baseInfo

async def setupComponentBaseInfo(self, baseGlyphName):
# Ideally we need the full "made of" graph, so we can normalize
# nested var composites, but then again, our local axis name -> fvar tag name
Expand Down

0 comments on commit febf239

Please sign in to comment.