forked from itfoundry/Poppins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-GoogleFonts.py
126 lines (108 loc) · 3.82 KB
/
build-GoogleFonts.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#! /usr/bin/env AFDKOPython
# encoding: UTF-8
from __future__ import division, absolute_import, print_function, unicode_literals
import hindkit
RELEASE = 4
COMMIT = 3
DATA = {
"roman": (
[
("100", -50),
("500", 44), # Manually generate "Poppins Devanagari-500.ufo".
("900", 150),
],
[
("Thin", -50, 250),
("ExtraLight", -25, 275),
("Light", 0, 300),
("Regular", 21, 400),
("Medium", 44, 500),
("SemiBold", 70, 600),
("Bold", 100, 700),
("ExtraBold", 125, 800),
("Black", 150, 900),
],
),
"italic": (
[
("100i", -50),
("500i", 44), # Manually generate "Poppins Devanagari-500i.ufo".
("900i", 150),
],
[
("Thin Italic", -50, 250),
("ExtraLight Italic", -25, 275),
("Light Italic", 0, 300),
("Italic", 21, 400),
("Medium Italic", 44, 500),
("SemiBold Italic", 70, 600),
("Bold Italic", 100, 700),
("ExtraBold Italic", 125, 800),
("Black Italic", 150, 900),
],
),
}
def main():
for master_scheme, style_scheme in DATA.values():
family = hindkit.Family(
trademark = "Poppins",
script_name = "Devanagari",
append_script_name = False,
client_name = "Google Fonts",
initial_release_year = 2014,
source_tag = "GoogleFonts",
)
family.set_masters(master_scheme)
family.set_styles(style_scheme)
i = family.info
i.openTypeNameDesigner = "Ninad Kale (Devanagari), Jonny Pinhorn (Latin)"
i.openTypeHheaAscender, i.openTypeHheaDescender, i.openTypeHheaLineGap = 1050, -350, 100
i.openTypeOS2WinAscent, i.openTypeOS2WinDescent = 1135, 627
project = hindkit.Project(
family,
release_commit = (RELEASE, COMMIT),
options = {
"prepare_mark_positioning": True,
"match_mI_variants": 1,
"position_marks_for_mI_variants": True,
"do_style_linking": True,
"additional_unicode_range_bits": [0, 1, 2],
"use_os_2_version_4": True,
"prefer_typo_metrics": True,
"run_autohint": True,
"build_ttf": True,
},
)
project.build()
# --- Overriding ---
hindkit.Project.directories["GOADB"] = "GlyphOrderAndAliasDB-GoogleFonts"
DIGITS = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
DIGITS_DEVANAGARI = ["dv" + i.title() for i in DIGITS]
hindkit.constants.DERIVABLE_GLYPHS.update(
{k: [v] for k, v in zip(DIGITS, DIGITS_DEVANAGARI)}
)
hindkit.constants.DERIVABLE_GLYPHS.update(
{"quoteright.ss01": ["apostrophemod.ss01"]}
)
def master_postprocess(self):
target_font = self.open()
for glyph in target_font:
glyph.clearAnchors()
self.import_from_font(
source_path = "resources/ITF Misc-Regular.ufo",
glyph_names_included = ".notdef zerowidthnonjoiner zerowidthjoiner dottedcircle".split(),
)
self.import_from_font(
source_path = "masters/Poppins Devanagari-{}.ufo".format(self.name),
import_anchors = True,
)
self.derive_glyphs([
"NULL", "CR", "nonbreakingspace",
"softhyphen", "divisionslash", "bulletoperator", "macronmod", "apostrophemod",
"apostrophemod.ss01",
] + DIGITS_DEVANAGARI)
hindkit.Master.postprocess = master_postprocess
hindkit.filters.POTENTIAL_BASES_FOR_LONG_mII.append("K_TA")
hindkit.FeatureMatches.mI_VARIANT_NAME_PATTERN = r"mI\.a\d\d"
# --- Executing ---
main()