Generates otf or ttf fonts using the Adobe FDK. This also autohints the generated fonts either with psautohint (cff) or ttfautohint (ttf) *root* is the root to find the source files in *outputPath* is the path to save the generated fonts to *kind* is either 'otf' or 'ttf'.
(root, outputPath, kind="otf")
| 649 | |
| 650 | |
| 651 | def makeSFNT(root, outputPath, kind="otf"): |
| 652 | """ |
| 653 | Generates otf or ttf fonts using the Adobe FDK. |
| 654 | |
| 655 | This also autohints the generated fonts either with psautohint (cff) or |
| 656 | ttfautohint (ttf) |
| 657 | |
| 658 | *root* is the root to find the source files in |
| 659 | *outputPath* is the path to save the generated fonts to |
| 660 | *kind* is either 'otf' or 'ttf'. |
| 661 | """ |
| 662 | |
| 663 | if kind == "ttf": |
| 664 | source = "ttf" |
| 665 | else: |
| 666 | source = "ufo" |
| 667 | |
| 668 | # make sure output dir contains no files |
| 669 | files = getFiles(outputPath, kind) |
| 670 | if len(files) != 0: |
| 671 | for file in files: |
| 672 | os.remove(file) |
| 673 | |
| 674 | print(f"🏗 Initial {kind.upper()} building") |
| 675 | files = getFiles(root, source) |
| 676 | outputFile = os.path.join(outputPath, "makeotf_output.txt") |
| 677 | if os.path.exists(outputFile): |
| 678 | os.remove(outputFile) |
| 679 | |
| 680 | printProgressBar(0, len(files), prefix=' ', suffix='Complete', length=50) |
| 681 | for i, file in enumerate(files): |
| 682 | |
| 683 | # Set the makeotf parameters |
| 684 | # -r is release mode |
| 685 | # -nshw quiets the "glyph not hinted" warnings, as we |
| 686 | # have yet to run the autohinter (we do that after fonts) |
| 687 | # are built |
| 688 | |
| 689 | args = ["makeotf", "-f", file, "-o", outputPath, "-r", "-nshw"] |
| 690 | run = subprocess.run(args, |
| 691 | stdout=subprocess.PIPE, |
| 692 | stderr=subprocess.STDOUT, |
| 693 | universal_newlines=True) |
| 694 | with open(outputFile, "a") as f: |
| 695 | f.write(run.stdout) |
| 696 | |
| 697 | printProgressBar(i + 1, len(files), prefix=' ', |
| 698 | suffix='Complete', length=50) |
| 699 | |
| 700 | print(f"🏗 {kind.upper()} table fixing") |
| 701 | files = getFiles(outputPath, kind) |
| 702 | printProgressBar(0, len(files), prefix=' ', suffix='Complete', length=50) |
| 703 | for i, file in enumerate(files): |
| 704 | font = TTFont(file) |
| 705 | nameTableTweak(font) |
| 706 | makeDSIG(font) |
| 707 | font.save(file) |
| 708 | printProgressBar(i + 1, len(files), prefix=' ', |
no test coverage detected