summaryrefslogtreecommitdiff
path: root/Makefile
blob: 66eac073c55f0f8ea65181d96261c1990fc89bec (plain)
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
# Targets:
#   all           Build all styles in all formats (default)
#   all_ttf       Build all styles as TrueType
#   all_otf       Build all styles as OpenType
#   all_hinted    Build all styles as autohinted TrueType
#   STYLE         Build STYLE in all formats (e.g. MediumItalic)
#   STYLE_hinted  Build STYLE in TTF and web formats with autohints
#   STYLE_ttf     Build STYLE as TrueType (e.g. MediumItalic_ttf)
#   zip           Build all styles as TrueType and package into a zip archive
#   install       Build all (web, ttf and otf) and install. Mac-only for now.
#   dist          Create a new release distribution. Does everything.
#
all: all_ttf all_otf
	$(MAKE) all_web -j

all_hinted: all_ttf all_ttf_hinted all_otf
	$(MAKE) all_web_hinted -j

VERSION := $(shell misc/version.py)

# generated.make is automatically generated by init.sh and defines depenencies for
# all styles and alias targets
include build/etc/generated.make

res_files := src/fontbuild.cfg src/diacritics.txt src/glyphlist.txt \
             src/features.fea src/glyphorder.txt

# UFO -> TTF & OTF (note that UFO deps are defined by generated.make)
build/tmp/InterUITTF/InterUI-%.ttf: $(res_files)
	misc/ufocompile --otf $*

build/tmp/InterUIOTF/InterUI-%.otf: build/tmp/InterUITTF/InterUI-%.ttf $(res_files)
	@true

# tmp/ttf -> dist
build/dist-unhinted/Inter-UI-%.ttf: build/tmp/InterUITTF/InterUI-%.ttf
	@mkdir -p build/dist-unhinted
	cp -a "$<" "$@"

# tmp/otf -> dist
build/dist-unhinted/Inter-UI-%.otf: build/tmp/InterUIOTF/InterUI-%.otf
	@mkdir -p build/dist-unhinted
	cp -a "$<" "$@"

# autohint
build/dist-hinted/Inter-UI-%.ttf: build/dist-unhinted/Inter-UI-%.ttf
	@mkdir -p build/dist-hinted
	ttfautohint \
	  --hinting-limit=256 \
	  --hinting-range-min=8 \
	  --hinting-range-max=64 \
	  --fallback-stem-width=256 \
	  --strong-stem-width=D \
	  --no-info \
	  --verbose \
	  "$<" "$@"

# TTF -> WOFF2
build/%.woff2: build/%.ttf
	woff2_compress "$<"

# TTF -> WOFF
build/%.woff: build/%.ttf
	ttf2woff -O -t woff "$<" "$@"

# TTF -> EOT (disabled)
# build/%.eot: build/%.ttf
# 	ttf2eot "$<" > "$@"

test: all_otf
	@misc/check-font.py build/dist-unhinted/*.otf

ZIP_FILE_DIST := build/release/Inter-UI-${VERSION}.zip
ZIP_FILE_DEV  := build/release/Inter-UI-${VERSION}-$(shell git rev-parse --short=10 HEAD).zip

# zip intermediate
build/.zip.zip: all_otf
	$(MAKE) all_web all_web_hinted -j
	@rm -rf build/.zip
	@rm -f build/.zip.zip
	@mkdir -p \
		"build/.zip/Inter UI (web)" \
		"build/.zip/Inter UI (web hinted)" \
		"build/.zip/Inter UI (TTF)" \
		"build/.zip/Inter UI (TTF hinted)" \
		"build/.zip/Inter UI (OTF)"
	@cp -a build/dist-unhinted/*.woff build/dist-unhinted/*.woff2 \
	  "build/.zip/Inter UI (web)/"
	@cp -a misc/doc/inter-ui.css "build/.zip/Inter UI (web)/"
	@cp -a build/dist-hinted/*.woff build/dist-hinted/*.woff2 \
		"build/.zip/Inter UI (web hinted)/"
	@cp -a misc/doc/inter-ui.css "build/.zip/Inter UI (web hinted)/"
	@cp -a build/dist-unhinted/*.ttf   "build/.zip/Inter UI (TTF)/"
	@cp -a build/dist-hinted/*.ttf     "build/.zip/Inter UI (TTF hinted)/"
	@cp -a build/dist-unhinted/*.otf   "build/.zip/Inter UI (OTF)/"
	@cp -a misc/doc/*.txt              "build/.zip/"
	@cp -a LICENSE.txt                 "build/.zip/"
	cd build/.zip && zip -v -X -r "../../build/.zip.zip" * >/dev/null && cd ../..
	@rm -rf build/.zip

# zip
build/release/Inter-UI-%.zip: build/.zip.zip
	@mkdir -p "$(shell dirname "$@")"
	@mv -f "$<" "$@"
	@echo write "$@"

zip: ${ZIP_FILE_DEV}
zip_dist: pre_dist test ${ZIP_FILE_DIST}

pre_dist:
	@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

dist: zip_dist
	$(MAKE) geninfo copy_docs_fonts -j8
	misc/versionize-css.py
	@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 src/fontbuild.cfg and commit"
	@echo ""
	@echo "——————————————————————————————————————————————————————————————————"

copy_docs_fonts:
	rm -rf docs/font-files
	mkdir docs/font-files
	cp -a build/dist-unhinted/*.woff build/dist-unhinted/*.woff2 build/dist-unhinted/*.otf docs/font-files/

install_ttf: all_ttf_unhinted
	$(MAKE) all_web -j
	@echo "Installing TTF files locally at ~/Library/Fonts/Inter UI"
	rm -rf ~/'Library/Fonts/Inter UI'
	mkdir -p ~/'Library/Fonts/Inter UI'
	cp -va build/dist-unhinted/*.ttf ~/'Library/Fonts/Inter UI'

install_ttf_hinted: all_ttf
	$(MAKE) all_web -j
	@echo "Installing autohinted TTF files locally at ~/Library/Fonts/Inter UI"
	rm -rf ~/'Library/Fonts/Inter UI'
	mkdir -p ~/'Library/Fonts/Inter UI'
	cp -va build/dist-hinted/*.ttf ~/'Library/Fonts/Inter UI'

install_otf: all_otf
	$(MAKE) all_web -j
	@echo "Installing OTF files locally at ~/Library/Fonts/Inter UI"
	rm -rf ~/'Library/Fonts/Inter UI'
	mkdir -p ~/'Library/Fonts/Inter UI'
	cp -va build/dist-unhinted/*.otf ~/'Library/Fonts/Inter UI'

install: install_otf


geninfo: docs/info.json docs/lab/glyphinfo.json docs/glyphs/metrics.json

src/glyphorder.txt: src/Inter-UI-Regular.ufo/lib.plist src/Inter-UI-Black.ufo/lib.plist src/diacritics.txt misc/gen-glyphorder.py
	misc/gen-glyphorder.py src/Inter-UI-*.ufo > src/glyphorder.txt

docs/info.json: misc/fontinfo.py docs/font-files/Inter-UI-*.otf
	misc/fontinfo.py -pretty docs/font-files/Inter-UI-Regular.otf > docs/info.json

docs/lab/glyphinfo.json: _local/UnicodeData.txt src/glyphorder.txt src/fontbuild.cfg misc/gen-glyphinfo.py
	misc/gen-glyphinfo.py -ucd _local/UnicodeData.txt \
	  src/Inter-UI-*.ufo > docs/lab/glyphinfo.json

docs/glyphs/metrics.json: src/glyphorder.txt src/fontbuild.cfg misc/gen-metrics-and-svgs.py $(Regular_ufo_d)
	misc/gen-metrics-and-svgs.py -f src/Inter-UI-Regular.ufo


# Download latest Unicode data
_local/UnicodeData.txt:
	@mkdir -p _local
	curl -s '-#' -o "$@" \
	  http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt

clean:
	rm -rf build/tmp/* build/dist-hinted build/dist-unhinted

.PHONY: all web clean install install_otf install_ttf deploy zip zip_dist pre_dist dist geninfo copy_docs_fonts all_hinted test