Using the values from the name map, generates a FontMenuNameDB file. *designspace* is a designspace object *root* is the directory where the FontMenuNameDB file is to be saved *name_map* is the name mapping dictionary
(designspace, root, name_map)
| 555 | |
| 556 | |
| 557 | def buildFontMenuDB(designspace, root, name_map): |
| 558 | """ |
| 559 | Using the values from the name map, generates a FontMenuNameDB file. |
| 560 | |
| 561 | *designspace* is a designspace object |
| 562 | *root* is the directory where the FontMenuNameDB file is to be saved |
| 563 | *name_map* is the name mapping dictionary |
| 564 | """ |
| 565 | |
| 566 | out = "" |
| 567 | for i in designspace.instances: |
| 568 | fn, sn, m1, ps, fm = name_map[(i.familyName, i.styleName)] |
| 569 | out += (f"[{ps}]\n" |
| 570 | f" f={fn}\n" |
| 571 | f" s={sn}\n" |
| 572 | f" l={fm}\n" |
| 573 | f" m=1,{m1}\n\n" |
| 574 | ) |
| 575 | |
| 576 | path = os.path.join(root, "FontMenuNameDB") |
| 577 | with open(path, "w") as f: |
| 578 | f.write(out) |
| 579 | |
| 580 | print("🏗 Made FontMenuDB") |
| 581 | |
| 582 | |
| 583 | def buildGlyphOrderAndAlias(fontPath, root): |