-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupdateNames.py
More file actions
61 lines (45 loc) · 1.88 KB
/
Copy pathupdateNames.py
File metadata and controls
61 lines (45 loc) · 1.88 KB
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
51
52
53
54
55
56
57
58
59
"""
This script copies and collects some data from the GlyphNameFormatter.
https://github.com/LettError/glyphNameFormatter
Note: don't run from RoboFont, as it will find the embedded GlyphNameFormatter,
and it really needs to look at the repository.
"""
import pprint
import os, shutil, time
import glyphNameFormatter
gnfRoot = os.path.dirname(glyphNameFormatter.__file__)
browserRoot = os.path.join(os.getcwd(), "lib")
# copy the latest name list
srcNamePath = os.path.join(gnfRoot, "names", "glyphNamesToUnicodeAndCategories_experimental.txt")
if os.path.exists(srcNamePath):
dstNamePth = os.path.join(browserRoot, "data", "glyphNamesToUnicode.txt")
print("srcNamePath", srcNamePath)
print("dstNamePth", dstNamePth)
shutil.copyfile(srcNamePath, dstNamePth)
# copy the joining types
srcJoiningTypesPath = os.path.join(gnfRoot, "data", "joiningTypes.txt")
if os.path.exists(srcJoiningTypesPath):
dstJoiningTypesPath = os.path.join(browserRoot, "data", "joiningTypes.txt")
print("srcJoiningTypesPath", srcJoiningTypesPath)
print("dstJoiningTypesPath", dstJoiningTypesPath)
shutil.copyfile(srcJoiningTypesPath, dstJoiningTypesPath)
# make a range name table
from glyphNameFormatter.unicodeRangeNames import getAllRangeNames, getRangeByName
ranges = {}
for rangeName in getAllRangeNames():
r = getRangeByName(rangeName)
if r is None:
print("unknown range name", rangeName)
continue
start, end = r
ranges[(start,end)] = rangeName
pyText = []
pyText.append(u"# -*- coding: UTF-8 -*-")
pyText.append(u"# Generated from glyphNameFormatter range names")
pyText.append(u"# Generated on %s" % time.strftime("%Y %m %d %H:%M:%S"))
pyText.append(u"unicodeRangeNames =" + pprint.pformat(ranges, indent=4))
pyPath = os.path.join(browserRoot, "unicodeRanges.py")
print("pyPath", pyPath)
f = open(pyPath, 'w')
f.write("\n".join(pyText))
f.close()