forked from rsms/inter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
382 lines (294 loc) · 11.6 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# Targets:
# all Build everything
# test Build and test everyything (implies all_check)
# install Build and install all OTF files. (currently Mac-only)
# zip Build a complete release-grade ZIP archive of all fonts.
# dist Create a new release distribution. Does everything.
#
# all_const Build all non-variable files
# all_const_hinted Build all non-variable files with hints
# all_var Build all variable files
# all_var_hinted Build all variable files with hints (disabled)
#
# all_otf Build all OTF files into FONTDIR/const
# all_ttf Build all TTF files into FONTDIR/const
# all_ttf_hinted Build all TTF files with hints into FONTDIR/const-hinted
# all_web, web Build all WOFF files into FONTDIR/const
# all_web_hinted Build all WOFF files with hints into FONTDIR/const-hinted
# all_var Build all variable font files into FONTDIR/var
# all_var_hinted Build all variable font files with hints into
# FONTDIR/var-hinted
#
# designspace Build build/ufo/Inter.designspace from src/Inter.glyphs
#
# Style-specific targets:
# STYLE_otf Build OTF file for STYLE into FONTDIR/const
# STYLE_ttf Build TTF file for STYLE into FONTDIR/const
# STYLE_ttf_hinted Build TTF file for STYLE with hints into
# FONTDIR/const-hinted
# STYLE_web Build WOFF files for STYLE into FONTDIR/const
# STYLE_web_hinted Build WOFF files for STYLE with hints into
# FONTDIR/const-hinted
# STYLE_check Build & check OTF and TTF files for STYLE
#
# "build" directory output structure:
# fonts
# const
# const-hinted
# var
# var-hinted (disabled)
#
FONTDIR = build/fonts
all: all_const all_const_hinted all_var
web: all_web
.PHONY: all web
all_const: all_otf all_ttf all_web
all_const_hinted: all_ttf_hinted all_web_hinted
var: \
$(FONTDIR)/var/Inter.var.woff2 \
$(FONTDIR)/var/Inter.var.otf
all_var: \
$(FONTDIR)/var/Inter.var.otf \
$(FONTDIR)/var/Inter.var.woff2 \
$(FONTDIR)/var/Inter-V.var.otf \
$(FONTDIR)/var/Inter-V.var.woff2 \
$(FONTDIR)/var/Inter-roman.var.otf \
$(FONTDIR)/var/Inter-roman.var.woff2 \
$(FONTDIR)/var/Inter-italic.var.otf \
$(FONTDIR)/var/Inter-italic.var.woff2
# Hinted variable font disabled. See https://github.com/rsms/inter/issues/75
# all_var_hinted: $(FONTDIR)/var-hinted/Inter.var.otf $(FONTDIR)/var-hinted/Inter.var.woff2
# .PHONY: all_var_hinted
.PHONY: all_const all_const_hinted var all_var
export PATH := $(PWD)/build/venv/bin:$(PATH)
# generated.make is automatically generated by init.sh and defines depenencies for
# all styles and alias targets
include build/etc/generated.make
# WOFF2 from OTF
build/%.var.woff2: build/%.var.otf
woff2_compress "$<"
# WOFF2 from TTF
build/%.woff2: build/%.ttf
woff2_compress "$<"
# WOFF from TTF
build/%.woff: build/%.ttf
ttf2woff -O -t woff "$<" "$@"
# VF OTF from UFO
$(FONTDIR)/var/Inter.var.otf: $(all_ufo_masters) version.txt
misc/fontbuild compile-var -o $@ $(FONTBUILD_FLAGS) build/ufo/Inter.designspace
$(FONTDIR)/var/Inter-V.var.otf: $(FONTDIR)/var/Inter.var.otf
misc/fontbuild rename --family "Inter V" -o $@ $<
$(FONTDIR)/var/Inter-%.var.otf: build/ufo/Inter-%.designspace $(all_ufo_masters) version.txt
misc/fontbuild compile-var -o $@ $(FONTBUILD_FLAGS) $<
misc/tools/fix-vf-meta.py $@
# OTF/TTF from UFO
$(FONTDIR)/const/Inter-%.otf: build/ufo/Inter-%.ufo version.txt
misc/fontbuild compile -o $@ $(FONTBUILD_FLAGS) build/ufo/Inter-$*.ufo
$(FONTDIR)/const/Inter-%.ttf: build/ufo/Inter-%.ufo version.txt
misc/fontbuild compile -o $@ $(FONTBUILD_FLAGS) build/ufo/Inter-$*.ufo
# DESIGNSPACE from GLYPHS
build/ufo/Inter-roman.designspace: build/ufo/Inter.designspace
build/ufo/Inter-italic.designspace: build/ufo/Inter.designspace
build/ufo/Inter.designspace: src/Inter.glyphs
@mkdir -p build/ufo
misc/fontbuild glyphsync -o build/ufo src/Inter.glyphs
# short-circuit Make for performance
src/Inter.glyphs:
@true
# make sure intermediate files are not gc'd by make
.PRECIOUS: build/ufo/Inter-*.designspace
designspace: build/ufo/Inter.designspace
.PHONY: designspace
# features
src/features: $(wildcard src/features/*)
@touch "$@"
@true
build/ufo/features: src/features
@mkdir -p build/ufo
@rm -f build/ufo/features
@ln -s ../../src/features build/ufo/features
# make sure intermediate UFOs are not gc'd by make
.PRECIOUS: build/ufo/Inter-%.ufo
# Note: The seemingly convoluted dependency graph above is required to
# make sure that glyphsync and instancegen are not run in parallel.
# hinted TTF files via autohint
$(FONTDIR)/const-hinted/%.ttf: $(FONTDIR)/const/%.ttf
mkdir -p "$(dir $@)"
ttfautohint --fallback-stem-width=256 --no-info "$<" "$@"
# python -m ttfautohint --fallback-stem-width=256 --no-info "$<" "$@"
# $(FONTDIR)/var-hinted/%.ttf: $(FONTDIR)/var/%.ttf
# mkdir -p "$(dir $@)"
# ttfautohint --fallback-stem-width=256 --no-info "$<" "$@"
# make sure intermediate TTFs are not gc'd by make
.PRECIOUS: $(FONTDIR)/const/%.ttf
.PRECIOUS: $(FONTDIR)/const/%.otf
.PRECIOUS: $(FONTDIR)/const-hinted/%.ttf
.PRECIOUS: $(FONTDIR)/var/%.var.otf
# check var
test_var: all_var
misc/fontbuild checkfont $(FONTDIR)/var/*.otf $(FONTDIR)/var/*.woff2
# test runs all tests
# Note: all_check_const is generated by init.sh and runs "fontbuild checkfont"
# on all otf and ttf files.
test: all_check_const test_var
@echo "test: all ok"
# check does the same thing as test, but without any dependency checks, meaning
# it will check whatever font files are already built.
check:
misc/fontbuild checkfont \
$(FONTDIR)/const/*.ttf \
$(FONTDIR)/const/*.otf \
$(FONTDIR)/const/*.woff2 \
$(FONTDIR)/var/*.otf \
$(FONTDIR)/var/*.woff2
@echo "check: all ok"
.PHONY: test check
# samples renders PDF and PNG samples
samples: $(FONTDIR)/samples all_samples_pdf all_samples_png
$(FONTDIR)/samples/%.pdf: $(FONTDIR)/const/%.otf $(FONTDIR)/samples
misc/tools/fontsample/fontsample -o "$@" "$<"
$(FONTDIR)/samples/%.png: $(FONTDIR)/const/%.otf $(FONTDIR)/samples
misc/tools/fontsample/fontsample -o "$@" "$<"
$(FONTDIR)/samples:
mkdir -p $@
.PHONY: samples
ZD = build/tmp/zip
# intermediate zip target that creates a zip file at build/tmp/a.zip
build/tmp/a.zip:
@rm -rf "$(ZD)"
@rm -f build/tmp/a.zip
@mkdir -p \
"$(ZD)/Inter" \
"$(ZD)/Inter (Hinted, for Windows)" \
"$(ZD)/Inter (Variable)" \
"$(ZD)/Inter (Variable, single axis)" \
"$(ZD)/Inter (Web)" \
"$(ZD)/Inter V (Variable)"
@#
@# copy font files
cp -a $(FONTDIR)/const/*.otf "$(ZD)/Inter/"
@#
cp -a $(FONTDIR)/const/*.woff \
$(FONTDIR)/const/*.woff2 \
$(FONTDIR)/var/Inter.var.woff2 \
$(FONTDIR)/var/Inter-italic.var.woff2 \
$(FONTDIR)/var/Inter-roman.var.woff2 \
misc/dist/inter.css \
"$(ZD)/Inter (Web)/"
cp -a $(FONTDIR)/const-hinted/*.woff \
$(FONTDIR)/const-hinted/*.woff2 \
$(FONTDIR)/const-hinted/*.ttf \
misc/dist/inter.css \
"misc/dist/about hinted fonts.txt" \
"$(ZD)/Inter (Hinted, for Windows)/"
@#
cp -a $(FONTDIR)/var/Inter.var.otf "$(ZD)/Inter (Variable)/Inter.otf"
cp -a $(FONTDIR)/var/Inter-roman.var.otf "$(ZD)/Inter (Variable, single axis)/Inter-roman.otf"
cp -a $(FONTDIR)/var/Inter-italic.var.otf "$(ZD)/Inter (Variable, single axis)/Inter-italic.otf"
@#
cp -a $(FONTDIR)/var/Inter-V.var.otf "$(ZD)/Inter V (Variable)/Inter-V.otf"
@#
@# copy misc stuff
cp -a misc/dist/install*.txt "$(ZD)/"
cp -a LICENSE.txt "$(ZD)/"
@#
@# zip
cd "$(ZD)" && zip -q -X -r "../../../$@" * && cd ../..
@rm -rf "$(ZD)"
# load version, used by zip and dist
VERSION := $(shell cat version.txt)
# distribution zip files
ZIP_FILE_DIST := build/release/Inter-${VERSION}.zip
# zip
build/release/Inter-%.zip: build/tmp/a.zip
@mkdir -p "$(shell dirname "$@")"
@mv -f "$<" "$@"
@echo write "$@"
@sh -c "if [ -f /usr/bin/open ]; then /usr/bin/open --reveal '$@'; fi"
zip: all
$(MAKE) check
$(MAKE) build/release/Inter-${VERSION}-$(shell git rev-parse --short=10 HEAD).zip
zip_dist: pre_dist
$(MAKE) check
$(MAKE) ${ZIP_FILE_DIST}
# distribution
pre_dist: all
@echo "Creating distribution for version ${VERSION}"
@if [ -f "${ZIP_FILE_DIST}" ]; \
then echo "${ZIP_FILE_DIST} already exists. Bump version or remove the zip file to continue." >&2; \
exit 1; \
fi
misc/tools/versionize.py
dist: zip_dist
$(MAKE) -j docs
@echo "——————————————————————————————————————————————————————————————————"
@echo ""
@echo "Next steps:"
@echo ""
@echo "1) Commit & push changes"
@echo ""
@echo "2) Create new release with ${ZIP_FILE_DIST} at"
@echo " https://github.com/rsms/inter/releases/new?tag=v${VERSION}"
@echo ""
@echo "3) Bump version in version.txt (to the next future version)"
@echo ""
@echo "——————————————————————————————————————————————————————————————————"
.PHONY: zip zip_dist pre_dist dist
docs: docs_fonts
$(MAKE) -j docs_info
docs_info: docs/_data/fontinfo.json \
docs/lab/glyphinfo.json \
docs/glyphs/metrics.json
docs_fonts:
rm -rf docs/font-files
mkdir docs/font-files
cp -a $(FONTDIR)/const/*.woff \
$(FONTDIR)/const/*.woff2 \
$(FONTDIR)/const/*.otf \
$(FONTDIR)/var/*.* \
docs/font-files/
.PHONY: docs docs_info docs_fonts
docs/_data/fontinfo.json: docs/font-files/Inter-Regular.otf misc/tools/fontinfo.py
misc/tools/fontinfo.py -pretty $< > docs/_data/fontinfo.json
docs/lab/glyphinfo.json: misc/tools/gen-glyphinfo.py build/ufo/Inter-Regular.ufo
misc/tools/gen-glyphinfo.py -ucd misc/UnicodeData.txt build/ufo/Inter-Regular.ufo > $@
docs/glyphs/metrics.json: misc/tools/gen-metrics-and-svgs.py build/ufo/Inter-Regular.ufo
misc/tools/gen-metrics-and-svgs.py build/ufo/Inter-Regular.ufo
# Helper target to download latest Unicode data. Nothing depends on this.
ucd_version := 12.1.0
update_UnicodeData:
@echo "# Unicode $(ucd_version)" > misc/UnicodeData.txt
curl '-#' "https://www.unicode.org/Public/$(ucd_version)/ucd/UnicodeData.txt" >> misc/UnicodeData.txt
# Google fonts
build/googlefonts/%: $(FONTDIR)/%
misc/fontbuild rename --compact-style -o $@ "$<"
googlefonts: googlefonts_pre googlefonts_all
googlefonts_pre:
@rm -rf build/googlefonts
@mkdir -p build/googlefonts/const build/googlefonts/var
.PHONY: googlefonts googlefonts_pre
# install targets
install_ttf: all_ttf_const
@echo "Installing TTF files locally at ~/Library/Fonts/Inter"
rm -rf ~/'Library/Fonts/Inter'
mkdir -p ~/'Library/Fonts/Inter'
cp -va $(FONTDIR)/const/*.ttf ~/'Library/Fonts/Inter'
install_ttf_hinted: all_ttf_hinted
@echo "Installing autohinted TTF files locally at ~/Library/Fonts/Inter"
rm -rf ~/'Library/Fonts/Inter'
mkdir -p ~/'Library/Fonts/Inter'
cp -va $(FONTDIR)/const-hinted/*.ttf ~/'Library/Fonts/Inter'
install_otf: all_otf
@echo "Installing OTF files locally at ~/Library/Fonts/Inter"
rm -rf ~/'Library/Fonts/Inter'
mkdir -p ~/'Library/Fonts/Inter'
cp -va $(FONTDIR)/const/*.otf ~/'Library/Fonts/Inter'
install_var_v: $(FONTDIR)/var/Inter-V.var.otf
mkdir -p ~/'Library/Fonts/Inter'
cp -va $(FONTDIR)/var/Inter-V.var.otf ~/'Library/Fonts/Inter/Inter-V.otf'
install: install_otf install_var_v
.PHONY: install install_otf install_ttf
# clean removes generated and built fonts in the build directory
clean:
rm -rvf build/tmp build/fonts build/ufo build/googlefonts
.PHONY: clean