-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
229 lines (196 loc) · 7.17 KB
/
Makefile
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/usr/bin/make -f
SHELL:=/bin/bash
PY=python3
FAMILY=Malini
STYLES=$(shell $(PY) tools/read_config.py styles)
SOURCEDIR=sources
FONTSDIR=fonts
PROOFDIR=proofs
TESTSDIR=tests
TTFDIR=${FONTSDIR}/ttf
OTFDIR=${FONTSDIR}/otf
WEBFONTSDIR=${FONTSDIR}/webfonts
UFODIR=${SOURCEDIR}/ufo
INSTALLDIR=~/.fonts/$(FAMILY)
UFO=$(STYLES:%=$(UFODIR)/$(FAMILY)-%.ufo)
.PHONY: $(STYLES) ufo clean glyphs build proofs autobuild update-deps init update
default: build
help:
@echo "Build targets"
@echo
@echo " make build: Builds the fonts and places them in the fonts/ directory"
@echo " make test: Tests the fonts with fontbakery"
@echo " make proof: Creates HTML proof documents in the proof/ directory"
@echo
build: ufo Malini
# Recursively watch the file changes and make the (debug) svgs.
# Useful in design workflow.
# Package inotify-tools are available in linux distros
autobuild:
while inotifywait -e MODIFY $(SOURCEDIR)/glyphs/; do $(MAKE) -C $(SOURCEDIR); done;
# Targets for preparing the glyphs from metapost and preparing master UFOs.
glyphs: $(STYLES)
$(STYLES):
@mkdir -p $(SOURCEDIR)/svgs/$@
VARIANT=$@ $(MAKE) -C $(SOURCEDIR)
$(UFODIR)/$(FAMILY)-%.ufo: %
@echo " BUILD UFO $(@F)"
@mkdir -p ${UFODIR}
$(PY) tools/builder.py --style $* --source $(SOURCEDIR)/svgs/$* --output $@
@ufonormalizer -q -m $@
@# remove dangling semicolons in features.fea which font editors cannot handle
@sed -i 's/ ;$\//g' $@/features.fea
ufo: glyphs $(UFO)
# Build targets for prepating the fonts from master UFO sources.
Malini: $(FONTSDIR)/Malini/ttf-variable\
$(FONTSDIR)/Malini/otf-variable \
$(FONTSDIR)/Malini/otf \
$(FONTSDIR)/Malini/ttf \
$(FONTSDIR)/Malini/webfonts \
$(FONTSDIR)/Malini/ufo
# Create ttf instances if a designspace exist
$(FONTSDIR)/%/ttf: %.designspace
fontmake --mm-designspace $*.designspace \
--filter DecomposeTransformedComponentsFilter \
--interpolate \
--flatten-components \
--verbose WARNING \
--output-dir $@ \
--output ttf \
--optimize-cff 0
$(PY) tools/fix_font.py $(FONTSDIR)/$*/ttf/*.ttf
# Create otf instances if a designspace exist
$(FONTSDIR)/%/otf : %.designspace
fontmake --mm-designspace $*.designspace \
--verbose WARNING \
--filter DecomposeTransformedComponentsFilter \
--flatten-components \
--interpolate \
--optimize-cff 1 \
--output-dir $@ \
--output otf
$(PY) tools/fix_font.py $@/*.otf
# Create ttf variablefont from the given designspace
$(FONTSDIR)/%/ttf-variable: ufo %.designspace
fontmake --mm-designspace $*.designspace \
--filter DecomposeTransformedComponentsFilter \
--flatten-components \
--verbose WARNING \
--output-dir $@ \
--output variable
$(PY) tools/fix_font.py $@/*.ttf
$(PY) tools/stat.py $* $@/*.ttf
# Create otf variablefont from the given designspace
$(FONTSDIR)/%/otf-variable : ufo %.designspace
fontmake --mm-designspace $*.designspace \
--filter DecomposeTransformedComponentsFilter \
--flatten-components \
--output-dir $@ \
--verbose WARNING \
--optimize-cff 1 \
--output variable-cff2
$(PY) tools/fix_font.py $@/*.otf
$(PY) tools/stat.py $* $@/*.otf
# Create UFO instances from the given designspace
# Note that ufo instance created for multi layer color fonts will be invalid
# See # See https://github.com/googlefonts/fontmake/issues/928#issuecomment-1227311804
$(FONTSDIR)/%/ufo: %.designspace
fontmake --mm-designspace $*.designspace \
--interpolate \
--output ufo
# Compile otf from UFO file. This target will be picked up only if designspace is missing for the variant
$(FONTSDIR)/%/otf: ${UFODIR}/%.ufo
fontmake --validate-ufo \
--verbose=WARNING \
--optimize-cff 1 \
--flatten-components \
--filter DecomposeTransformedComponentsFilter \
--output otf \
--output-dir $@ \
--ufo-paths $(UFODIR)/$*.ufo
$(PY) tools/fix_font.py $@/*
# Compile ttf from UFO file. This target will be picked up only if designspace is missing for the variant
$(FONTSDIR)/%/ttf: ${UFODIR}/%.ufo
@fontmake --verbose=WARNING \
--output ttf \
--flatten-components \
--filter DecomposeTransformedComponentsFilter \
--optimize-cff 1 \
--output-dir $@ \
--ufo-paths $(UFODIR)/$*.ufo
$(PY) tools/fix_font.py $@/*.ttf
# Package the ufo in fonts directory, directly from the source UFO.
$(FONTSDIR)/%/ufo: ${UFODIR}/%.ufo
@cp -r $</ $@/
# Create woff2 formatted webfonts for all the otfs available
# Could be done using fonttools but using a python script to avoid hassles of loop
# and filename mangling in Makefile
$(FONTSDIR)/%/webfonts:
@mkdir -p $@
$(PY) tools/gen_webfonts.py $(FONTSDIR)/$*/**/*.otf
clean:
@find -iname "*.pyc" -delete
@rm -rf $(FONTSDIR) $(PROOFDIR)
proofs:
@mkdir -p ${PROOFDIR}
hb-view $(FONTSDIR)/Malini/otf-variable/Malini-VF.otf \
--font-ptem 10 \
--margin 100 \
--line-space 2.4 \
--foreground=333333 \
--text-file $(TESTSDIR)/ligatures.txt \
--output-file $(PROOFDIR)/ligatures.pdf;
hb-view $(FONTSDIR)/Malini/otf-variable/Malini-VF.otf \
--font-ptem 10 \
--margin 100 \
--line-space 2.4 \
--foreground=333333 \
--text-file $(TESTSDIR)/content.txt \
--output-file $(PROOFDIR)/content.pdf;
hb-view $(FONTSDIR)/Malini/otf-variable/Malini-VF.otf \
--font-ptem 10 \
--margin 100 \
--line-space 2.4 \
--foreground=333333 \
--text-file $(TESTSDIR)/kerning.txt \
--output-file $(PROOFDIR)/kerning.pdf ;
cat $(TESTSDIR)/paragraphs.english.txt | fold -sw 80 | hb-view $(FONTSDIR)/Malini/otf-variable/Malini-VF.otf \
--font-ptem 10 \
--margin 100 \
--line-space 2.4 \
--foreground=333333 \
--output-file $(PROOFDIR)/paragraphs.english.pdf ;
test: proofs
# fontbakery check-fontval $(FONTSDIR)/$(FAMILY)-Regular.ttf <- enable when https://github.com/microsoft/Font-Validator/issues/62 fixed
# fontbakery check-ufo-sources $(SOURCEDIR)/ufo/$(FAMILY)-Regular.ufo
fontbakery check-opentype $(FONTSDIR)/Malini/otf-variable/Malini-VF.otf
fontbakery check-googlefonts --full-lists --config fontbakery.yaml --html tests/fontbakery-report.html --ghmarkdown tests/fontbakery-report.md $(FONTSDIR)/Malini/ttf-variable/Malini-VF.ttf
install: $(FONTSDIR)/Malini/otf-variable
@mkdir -p $(INSTALLDIR);
@cp $(FONTSDIR)/Malini/otf-variable/Malini-VF.otf $(INSTALLDIR);
@fc-cache -fr
release:
.PHONY: release
release:
@$(eval VERSION=$(shell git describe --tags `git rev-list --tags --max-count=1`))
@echo "Creating release for version $(VERSION)"
# Tar files - Malini
tar czvf $(FONTSDIR)/Malini-$(VERSION).tar.gz *.conf OFL.txt README.md $(FONTSDIR)/Malini
sha256sum $(FONTSDIR)/Malini-$(VERSION).tar.gz > $(FONTSDIR)/Malini-$(VERSION).tar.gz.sha256
md5sum $(FONTSDIR)/Malini-$(VERSION).tar.gz > $(FONTSDIR)/Malini-$(VERSION).tar.gz.md5
# Zip files
zip -r $(FONTSDIR)/Malini-$(VERSION).zip README.md OFL.txt $(FONTSDIR)/Malini
sha256sum $(FONTSDIR)/Malini-$(VERSION).zip > $(FONTSDIR)/Malini-$(VERSION).zip.sha256
md5sum $(FONTSDIR)/Malini-$(VERSION).zip > $(FONTSDIR)/Malini-$(VERSION).zip.md5
init:
pip-sync
pip check
update: update-deps init
update-deps:
export PIP_REQUIRE_VIRTUALENV=true
pip install --upgrade pip-tools pip wheel
pip-compile --upgrade --extra=tests,dev -o requirements.txt pyproject.toml
# Vertical Metrics Reporting
metrics-report:
# May need `pip install font-line` to install font-line
font-line report $(FONTSDIR)/Malini/otf-variable/*.otf