diff --git a/src/fontra_compile/builder.py b/src/fontra_compile/builder.py index e5a484b..67a9202 100644 --- a/src/fontra_compile/builder.py +++ b/src/fontra_compile/builder.py @@ -702,6 +702,12 @@ def prepareXAdvanceVariations(glyph: VariableGlyph, glyphSources): return [glyph.layers[source.layerName].glyph.xAdvance for source in glyphSources] +def computeLeftSideBearing(path: Path | PackedPath, useTightBounds: bool) -> int: + boundsPen = (BoundsPen if useTightBounds else ControlBoundsPen)(None) + path.drawPoints(PointToSegmentPen(boundsPen)) + return otRound(boundsPen.bounds[0]) if boundsPen.bounds is not None else 0 + + def buildTTGlyph(glyph, glyphSources, defaultLayerGlyph, model): ttGlyphPen = TTGlyphPointPen(None) defaultLayerGlyph.path.drawPoints(ttGlyphPen) @@ -781,12 +787,6 @@ def buildCharString(glyph, glyphSources, defaultLayerGlyph, model): return charString, charStringSupports -def computeLeftSideBearing(path: Path | PackedPath, useTightBounds: bool) -> int: - boundsPen = (BoundsPen if useTightBounds else ControlBoundsPen)(None) - path.drawPoints(PointToSegmentPen(boundsPen)) - return otRound(boundsPen.bounds[0]) if boundsPen.bounds is not None else 0 - - def prepareCFFVarData(charStrings, charStringSupports): vsindexMap = {} for supports in charStringSupports.values():