Last active
August 22, 2024 02:55
-
-
Save chrissimpkins/d0898e9580b9aa8f2ae692afe724bf93 to your computer and use it in GitHub Desktop.
Converts the isFixedPitch post table setting in a font to a value of 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
### DEPENDENCY: | |
# fontTools Python library | |
# ==> https://github.com/fonttools/fonttools | |
# ==> Install: pip install fonttools | |
### USAGE: | |
# python fpfix.py [filepath to font] | |
import sys | |
from fontTools import ttLib | |
if len(sys.argv) < 2: | |
sys.stderr.write("[fpfix.py] ERROR: Please enter a path to the font file") | |
sys.exit(1) | |
try: | |
tt = ttLib.TTFont(sys.argv[1]) | |
post = tt["post"]__dict___ | |
post["isFixedPitch"] = 1 | |
tt.save(outfile) | |
print("[fpfix.py]: '" + sys.argv[1] + "' fixed pitch setting was changed to 1 in the post table") | |
except Exception as e: | |
sys.stderr.write("[fpfix.py] : ERROR: Unable to update the font isFixedPitch setting. " + str(e)) | |
sys.exit(1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment