-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
169 lines (137 loc) · 4.99 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
# Copyright (c) 2020-2024 Khaled Hosny
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
NAME = ReemKufi
COLRv0 = Fun
COLRv1 = Ink
SHELL = bash
MAKEFLAGS := -srj
PYTHON := venv/bin/python3
SOURCEDIR = sources
SCRIPTDIR = scripts
FONTDIR = fonts
BUILDDIR = build
FONTS = \
${NAME} \
${NAME}${COLRv0} \
${NAME}${COLRv1}-Regular # ${NAME}${COLRv1}-Bold
TTF = $(FONTS:%=${FONTDIR}/%.ttf)
SVG = FontSample.svg
GLYPHSFILE = ${SOURCEDIR}/${NAME}.glyphspackage
export SOURCE_DATE_EPOCH ?= $(shell stat -c "%Y" ${GLYPHSFILE})
TAG = $(shell git describe --tags --abbrev=0)
VERSION = ${TAG:v%=%}
DIST = ${NAME}-${VERSION}
define generate_fonts
mkdir -p $(dir $(3));
${PYTHON} -m fontmake \
--mm-designspace $(2) \
--output $(1) \
--output-path $(3) \
$(if $(4),--interpolate '.* $(4)',) \
--verbose WARNING \
--overlaps-backend pathops \
--optimize-cff 1 \
--flatten-components \
--filter ... \
--filter "alifTools.filters::ClearPlaceholdersFilter()" \
--filter "alifTools.filters::FontVersionFilter(fontVersion=${VERSION})" \
;
endef
.SECONDARY:
.ONESHELL:
.PHONY: all clean dist ttf doc
all: ttf doc
ttf: ${TTF}
doc: ${SVG}
.SECONDARY:
SVGS_ = $(notdir $(wildcard $(SOURCEDIR)/svg/Regular/*.svg))
SVGS = ${SVGS_:%=\%/%}
COLRDIR = ${BUILDDIR}/colr
${COLRDIR}/%.svg: ${SOURCEDIR}/svg/%.svg
$(info PICO ${@F})
mkdir -p ${@D}
picosvg --output_file $@ $<
${COLRDIR}/%/colr.toml: colr.toml
mkdir -p ${@D}
cp $< $@
%/colr.fea:
mkdir -p ${@D}
touch $@
%/glyphmap.csv: ${GLYPHSFILE}
mkdir -p ${@D}
${PYTHON} ${SCRIPTDIR}/mkglyphmap.py $< ${@D}
%/colr.ttf: %/colr.toml %/glyphmap.csv %/colr.fea ${SVGS}
$(info MAKE ${@F})
${PYTHON} -m nanoemoji.write_font -v -1 \
--config_file $< \
--glyphmap_file $*/glyphmap.csv \
--color_format glyf_colr_1 \
--fea_file $*/colr.fea \
--output_file $@
%/svg.ttf: %/colr.toml %/glyphmap.csv %/colr.fea ${SVGS}
$(info MAKE ${@F})
${PYTHON} -m nanoemoji.write_font -v -1 \
--config_file $< \
--glyphmap_file $*/glyphmap.csv \
--color_format untouchedsvg \
--fea_file $*/colr.fea \
--output_file $@
%/colr.ufo: %/colr.toml %/glyphmap.csv %/colr.fea ${SVGS}
$(info MAKE ${@F})
${PYTHON} -m nanoemoji.write_font -v -1 \
--config_file $< \
--glyphmap_file $*/glyphmap.csv \
--fea_file $*/colr.fea \
--output_file $@
${FONTDIR}/${NAME}${COLRv1}-%.ttf: ${BUILDDIR}/${NAME}.designspace ${COLRDIR}/%/colr.ttf ${COLRDIR}/%/svg.ttf
$(info MAKE ${@F})
$(call generate_fonts,ttf,$<,$@,$(*F))
${PYTHON} ${SCRIPTDIR}/mknocolr.py $@ $@
${PYTHON} ${SCRIPTDIR}/mkcolrv1.py $@ ${COLRDIR}/$*/colr.ttf ${COLRDIR}/$*/svg.ttf $@
${FONTDIR}/${NAME}${COLRv0}.ttf: ${BUILDDIR}/${NAME}.ttf
$(info MAKE ${@F})
mkdir -p ${@D}
${PYTHON} ${SCRIPTDIR}/mkcolrv0.py $< $@ ${COLRv0}
${BUILDDIR}/${NAME}.ttf: ${BUILDDIR}/${NAME}.designspace
$(info MAKE ${@F})
$(call generate_fonts,variable,$<,$@)
${FONTDIR}/${NAME}.ttf: ${BUILDDIR}/${NAME}.ttf
mkdir -p ${@D}
${PYTHON} ${SCRIPTDIR}/mknocolr.py $< $@
${BUILDDIR}/${NAME}.designspace: ${GLYPHSFILE}
$(info GEN ${@F})
${PYTHON} -m glyphsLib glyphs2ufo \
-m ${BUILDDIR} \
--minimal \
--generate-GDEF \
--write-public-skip-export-glyphs \
--no-preserve-glyphsapp-metadata \
--no-store-editor-state \
$<
${SVG}: ${FONTDIR}/${NAME}.ttf
$(info SVG ${@F})
${PYTHON} -m alifTools.sample $< \
--features="+cv01,-cv01[6],-cv01[32:36],+cv02[40],-cv01[45:]" \
--foreground=1F2328 \
--dark-foreground=D1D7E0 \
-o $@
dist: ${TTF}
$(info DIST ${DIST}.zip)
install -Dm644 -t ${DIST} ${TTF}
install -Dm644 -t ${DIST} README.md
install -Dm644 -t ${DIST} OFL.txt
zip -rq ${DIST}.zip ${DIST}
clean:
rm -rf ${TTF} ${SVG} ${BUILDDIR} ${DIST} ${DIST}.zip