diff --git a/src/fontra/backends/designspace.py b/src/fontra/backends/designspace.py index 943f84302..a66f92f20 100644 --- a/src/fontra/backends/designspace.py +++ b/src/fontra/backends/designspace.py @@ -281,6 +281,16 @@ async def putGlyph(self, glyphName, glyph, unicodes): revLayerNameMapping = reverseSparseDict(layerNameMapping) + haveVariableComponents = any( + any( + compo.location + or compo.transformation.tCenterX + or compo.transformation.tCenterY + for compo in layer.glyph.components + ) + for layer in glyph.layers.values() + ) + modTimes = set() usedLayers = set() for layerName, layer in glyph.layers.items(): @@ -297,7 +307,9 @@ async def putGlyph(self, glyphName, glyph, unicodes): else: layerGlyph = readGlyphOrCreate(glyphSet, glyphName, unicodes) - drawPointsFunc = populateUFOLayerGlyph(layerGlyph, layer.glyph) + drawPointsFunc = populateUFOLayerGlyph( + layerGlyph, layer.glyph, haveVariableComponents + ) glyphSet.writeGlyph(glyphName, layerGlyph, drawPointsFunc=drawPointsFunc) if writeGlyphSetContents: # FIXME: this is inefficient if we write many glyphs @@ -740,14 +752,18 @@ def readGlyphOrCreate( return layerGlyph -def populateUFOLayerGlyph(layerGlyph: UFOGlyph, staticGlyph: StaticGlyph) -> None: +def populateUFOLayerGlyph( + layerGlyph: UFOGlyph, + staticGlyph: StaticGlyph, + forceVariableComponents: bool = False, +) -> None: pen = RecordingPointPen() layerGlyph.width = staticGlyph.xAdvance layerGlyph.height = staticGlyph.yAdvance staticGlyph.path.drawPoints(pen) variableComponents = [] for component in staticGlyph.components: - if component.location: + if component.location or forceVariableComponents: # It's a variable component varCoDict = {"base": component.name, "location": component.location} if component.transformation != DecomposedTransform():