-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.py
49 lines (42 loc) · 1.41 KB
/
build.py
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
import fontforge
import psMat
import unicodedata
font = fontforge.open("KJV1611.sfd")
font.encoding = "UnicodeBMP"
import spaces
for k in spaces.Spaces.keys():
font.createChar(k)
for k, v in spaces.Spaces.items():
font[k].width = v
scPUA = 0xE500
smallcaps = list()
def createSC(font, glyph, scPUA):
font.selection.select(glyph)
font.copyReference()
font.createChar(scPUA)
font.selection.select(scPUA)
font.paste()
font[scPUA].transform(psMat.scale(0.78))
font[scPUA].glyphname = glyph.glyphname + '.sc'
for glyph in font.glyphs():
enc = chr(glyph.encoding)
if unicodedata.category(enc) == "Lu":
print(enc, hex(ord(enc)))
createSC(font, glyph, scPUA)
smallcaps.append((enc, glyph.glyphname))
scPUA+=1
scfea = open("smallcaps.fea", "w+")
scfea.write("languagesystem DFLT dflt; languagesystem latn dflt; languagesystem grek dflt; languagesystem cyrl dflt;")
scfea.write("feature c2sc {\n\tlookup c2sc1 {\n")
for sc in smallcaps:
scfea.write("\t\tsub {0} by {0}.sc;\n".format(sc[1]))
scfea.write("\t} c2sc1;\n} c2sc;")
scfea.close()
font.selection.select(("unicode","ranges"),0xE000,0xE0FF)
font.clear()
font.selection.all()
font.unlinkReferences()
font.removeOverlap()
font.mergeFeature("features.fea")
font.mergeFeature("smallcaps.fea")
font.generate("KJV1611.otf", flags=("opentype", "no-hints", "no-flex"))