MCPcopy
hub / github.com/arrowtype/recursive / buildGlyphOrderAndAlias

Function buildGlyphOrderAndAlias

mastering/build_static.py:583–607  ·  view source on GitHub ↗

Using the font's glyphOrder and postscriptNames, generates a GlyphOrderAndAliasDB file. *fontPath* is a `string` path to a UFO *root* is the directory to save the GlyphOrderAndAliasDB to

(fontPath, root)

Source from the content-addressed store, hash-verified

581
582
583def buildGlyphOrderAndAlias(fontPath, root):
584 """
585 Using the font's glyphOrder and postscriptNames, generates a
586 GlyphOrderAndAliasDB file.
587
588 *fontPath* is a `string` path to a UFO
589 *root* is the directory to save the GlyphOrderAndAliasDB to
590 """
591
592 font = Font(fontPath)
593 order = font.glyphOrder
594 mapping = font.lib["public.postscriptNames"]
595 path = os.path.join(root, "GlyphOrderAndAliasDB")
596 with open(path, "w") as f:
597 for name in order:
598 if name in font.keys():
599 glyph = font[name]
600 finalName = mapping[name]
601 if len(glyph.unicodes) > 1:
602 unicodes = [f"uni{uni:04X}" for uni in glyph.unicodes]
603 out = f"{finalName}\t{name}\t{','.join(unicodes)}\n"
604 else:
605 out = f"{finalName}\t{name}\n"
606 f.write(out)
607 f.write("\n")
608
609
610def nameTableTweak(font):

Callers 1

buildFilesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected