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)
| 581 | |
| 582 | |
| 583 | def 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 | |
| 610 | def nameTableTweak(font): |