使用 python 操作 fontforge 轉換字型檔
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| import sys
import fontforge
def main(): fontFilePath = sys.argv[1]
originFile=fontforge.open(fontFilePath)
originFile.selection.select(("ranges", "unicode"), 0xe000, 0xf8ff)
originFile.copy()
newFile=fontforge.font()
newFile.sfnt_names = originFile.sfnt_names
newFile.encoding = originFile.encoding
newFile.em = originFile.em
newFile.layers['Fore'].is_quadratic = originFile.layers['Fore'].is_quadratic
newFile.selection.select(("ranges", "unicode"), 0xe000, 0xf8ff)
newFile.paste()
newFile.fontname="EUDC"
newFile.generate("EUDC.woff")
originFile.close()
main()
|
執行 Python Script
使用 FontForge 執行 Python Script
1
| fontforge -script font.py [FontFilePath]
|