summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/fonts/xits/postprocess.py
blob: af04a5fd7c292b0e87f2c30e29a27c2cf8f15f95 (plain)
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
#!/usr/bin/env python
import sys
import warnings
from fontTools import ttLib

# suppress noisy DeprecationWarnings in fontTools
warnings.filterwarnings("ignore",category=DeprecationWarning)

font = ttLib.TTFont(sys.argv[1])

MS_Platform_ID  = 3
MS_Enc_ID       = 1
MS_Lang_US_ID   = 0x409

FullName_ID = 4

name = font["name"]
cff  = font["CFF "]

psname = cff.cff.fontNames[0]

# set MS full name to psname
# per name table spec
fullname = name.getName(FullName_ID, MS_Platform_ID, MS_Enc_ID, MS_Lang_US_ID)
fullname.string = psname.encode("utf_16_be")

font.save(sys.argv[1] + ".post")