diff --git a/Lib/fontgoggles/compile/ufoCompiler.py b/Lib/fontgoggles/compile/ufoCompiler.py index c54af62d..189b27ec 100644 --- a/Lib/fontgoggles/compile/ufoCompiler.py +++ b/Lib/fontgoggles/compile/ufoCompiler.py @@ -35,7 +35,7 @@ def compileUFOToFont(ufoPath): if ".notdef" not in glyphOrder: # We need a .notdef glyph, so let's make one. glyphOrder.insert(0, ".notdef") - cmap, revCmap, anchors = fetchCharacterMappingAndAnchors(glyphSet, ufoPath, ufo2=ufo2) + widths, cmap, revCmap, anchors = fetchGlyphInfo(glyphSet, ufoPath, ufo2=ufo2) fb = FontBuilder(round(info.unitsPerEm)) fb.setupGlyphOrder(glyphOrder) fb.setupCharacterMap(cmap) @@ -46,7 +46,7 @@ def compileUFOToFont(ufoPath): # changes. ttFont["FGAx"] = newTable("FGAx") ttFont["FGAx"].data = pickle.dumps(anchors) - ufo = MinimalFontObject(ufoPath, reader, revCmap, anchors) + ufo = MinimalFontObject(ufoPath, reader, widths, revCmap, anchors) feaComp = FeatureCompiler(ufo, ttFont) try: feaComp.compile() @@ -68,13 +68,15 @@ def compileUFOToPath(ufoPath, ttPath): ttFont.save(ttPath, reorderTables=False) -_unicodeOrAnchorGLIFPattern = re.compile(rb'(<\s*(anchor|unicode)\s+([^>]+)>)') +_tagGLIFPattern = re.compile(rb'(<\s*(advance|anchor|unicode)\s+([^>]+)>)') _ufo2AnchorPattern = re.compile(rb"\s+(]+move[^>]+name[^>]+>)\s+") _unicodeAttributeGLIFPattern = re.compile(rb'hex\s*=\s*\"([0-9A-Fa-f]+)\"') +_widthAttributeGLIFPattern = re.compile(rb'width\s*=\s*\"([0-9A-Fa-f]+)\"') -def fetchCharacterMappingAndAnchors(glyphSet, ufoPath, glyphNames=None, ufo2=False): +def fetchGlyphInfo(glyphSet, ufoPath, glyphNames=None, ufo2=False): # This seems about 2.3 times faster than reader.getCharacterMapping() + widths = {} cmap = {} # unicode: glyphName revCmap = {} anchors = {} # glyphName: [(anchorName, x, y), ...] @@ -86,12 +88,13 @@ def fetchCharacterMappingAndAnchors(glyphSet, ufoPath, glyphNames=None, ufo2=Fal if b"