git clone https://git.lucas.co/Myna.git
build.py (1.3K)
1 import fontforge
2 import math
3 import psMat
4
5 def mkFont(name, weight):
6 font = fontforge.open(name + ".sfd")
7 font.mergeFeature("features.fea")
8 font.generate("./fonts/" + name + ".otf")
9 font.generate("./fonts/" + name + ".ttf")
10
11 font.selection.all()
12 angle = 12
13 font.transform(psMat.skew(angle * math.pi / 180))
14
15 font.familyname = "Myna"
16 font.weight = weight
17 font.italicangle = -angle
18
19 if weight == "Bold":
20 subfamily = "Bold Italic"
21 # 0x01 (Italic) + 0x20 (Bold) = 0x21
22 font.os2_stylemap = 0x21
23 full_name = "Myna Bold Oblique"
24 else:
25 subfamily = "Italic"
26 font.os2_stylemap = 0x01
27 full_name = "Myna Regular Oblique"
28
29 font.fullname = full_name
30 font.fontname = full_name.replace(" ", "")
31
32 # This is the critical part for app recognition:
33 font.appendSFNTName("English (US)", "SubFamily", subfamily)
34
35 # Preferred Style
36 # font.appendSFNTName("English (US)", "Preferred Style", weight + " Oblique")
37
38 # 7th is Letterform where 9 = Oblique and 2 = Italic
39 panoseL = list(font.os2_panose)
40 panoseL[7] = 9
41 font.os2_panose = tuple(panoseL)
42
43 font.generate("./fonts/" + name + "Oblique.otf")
44 font.generate("./fonts/" + name + "Oblique.ttf")
45 font.close()
46
47
48 mkFont("Myna-Regular", "Regular")
49 mkFont("Myna-Bold", "Bold")