forked from trueroad/HaranoAjiFonts-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_font.sh
executable file
·271 lines (243 loc) · 8.65 KB
/
make_font.sh
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
#!/bin/sh
SRC_FONTBASE=$1
CMAP=$2
TTXVER=`ttx --version`
TOOLVER="ttx ${TTXVER}"
cd build/${SRC_FONTBASE}
BASEDIR=../..
BINDIR=${BASEDIR}/bin
TTXDIR=${BASEDIR}/ttx
DOWNLOADDIR=${BASEDIR}/download
SCRIPTDIR=${BASEDIR}/script
case "${SRC_FONTBASE}" in
SourceHanSans* )
AI0_SOURCEHAN=${DOWNLOADDIR}/AI0-SourceHanSans
AJ1X_KANJI=${DOWNLOADDIR}/SourceHanSans/aj16-kanji.txt
FONT_TYPE=Sans
;;
SourceHanSerif* )
AI0_SOURCEHAN=${DOWNLOADDIR}/AI0-SourceHanSerif
AJ1X_KANJI=${DOWNLOADDIR}/SourceHanSerif/aj16-kanji.txt
FONT_TYPE=Serif
;;
* )
echo invalid font name
exit 1
;;
esac
echo deleting old files...
rm -f *.ttx *.log \
|| { echo error; exit 1; }
echo "making conversion table (from cmap and CMap)..."
${BINDIR}/make_conv_table \
${TTXDIR}/${SRC_FONTBASE}._c_m_a_p.ttx ${DOWNLOADDIR}/${CMAP} \
> table-cmap.tbl 2> table-cmap.log \
|| { echo error; exit 1; }
echo "making conversion table (from JISX0208-SourceHan-Mapping.txt)..."
${BINDIR}/make_jisx0208_table \
${DOWNLOADDIR}/JISX0208-SourceHan-Mapping.txt ${FONT_TYPE} \
> table-jisx0208.tbl 2> table-jisx0208.log \
|| { echo error; exit 1; }
echo "making conversion table (from AI0-SourceHan and aj16-kanji.txt)..."
${BINDIR}/make_kanji_table \
${AI0_SOURCEHAN} ${AJ1X_KANJI} \
> table-kanji.tbl 2> table-kanji.log \
|| { echo error; exit 1; }
echo merging convertion tables...
${BINDIR}/merge_table \
table-cmap.tbl table-kanji.tbl \
> table01.tbl 2> table01.log \
|| { echo error; exit 1; }
${BINDIR}/merge_table \
table01.tbl table-jisx0208.tbl \
> table10.tbl 2> table10.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature fwid)..."
${BINDIR}/make_feature_table \
table10.tbl fwid ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-fwid.tbl 2> table-fwid.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature hwid)..."
${BINDIR}/make_feature_table \
table10.tbl hwid ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-hwid.tbl 2> table-hwid.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature pwid)..."
${BINDIR}/make_feature_table \
table10.tbl pwid ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-pwid.tbl 2> table-pwid.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature ruby)..."
${BINDIR}/make_feature_table \
table10.tbl ruby ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-ruby.tbl 2> table-ruby.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature vert)..."
${BINDIR}/make_feature_table \
table10.tbl vert ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-vert.tbl 2> table-vert.log \
|| { echo error; exit 1; }
echo "merging convertion tables (OpenType features)..."
${BINDIR}/merge_table \
table-fwid.tbl table10.tbl \
> table11.tbl 2> table11.log \
|| { echo error; exit 1; }
${BINDIR}/merge_table \
table-hwid.tbl table11.tbl \
> table12.tbl 2> table12.log \
|| { echo error; exit 1; }
${BINDIR}/merge_table \
table-pwid.tbl table12.tbl \
> table13.tbl 2> table13.log \
|| { echo error; exit 1; }
${BINDIR}/merge_table \
table-ruby.tbl table13.tbl \
> table14.tbl 2> table14.log \
|| { echo error; exit 1; }
${BINDIR}/merge_table \
table-vert.tbl table14.tbl \
> table20.tbl 2> table20.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature fwid) pass 2..."
${BINDIR}/make_feature_table \
table20.tbl fwid ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-fwid2.tbl 2> table-fwid2.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature hwid) pass 2..."
${BINDIR}/make_feature_table \
table20.tbl hwid ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-hwid2.tbl 2> table-hwid2.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature pwid) pass 2..."
${BINDIR}/make_feature_table \
table20.tbl pwid ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-pwid2.tbl 2> table-pwid2.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature ruby) pass 2..."
${BINDIR}/make_feature_table \
table20.tbl ruby ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-ruby2.tbl 2> table-ruby2.log \
|| { echo error; exit 1; }
echo "making conversion table (OpenType feature vert) pass 2..."
${BINDIR}/make_feature_table \
table20.tbl vert ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
${DOWNLOADDIR}/aj17-gsub-jp04.fea \
> table-vert2.tbl 2> table-vert2.log \
|| { echo error; exit 1; }
echo "merging convertion tables (OpenType features) pass 2..."
${BINDIR}/merge_table \
table-fwid2.tbl table20.tbl \
> table21.tbl 2> table21.log \
|| { echo error; exit 1; }
${BINDIR}/merge_table \
table-hwid2.tbl table21.tbl \
> table22.tbl 2> table22.log \
|| { echo error; exit 1; }
${BINDIR}/merge_table \
table-pwid2.tbl table22.tbl \
> table23.tbl 2> table23.log \
|| { echo error; exit 1; }
${BINDIR}/merge_table \
table-ruby2.tbl table23.tbl \
> table24.tbl 2> table24.log \
|| { echo error; exit 1; }
${BINDIR}/merge_table \
table-vert2.tbl table24.tbl \
> table.tbl 2> table.log \
|| { echo error; exit 1; }
echo making glyphorder...
${BINDIR}/make_glyphorder \
table.tbl \
> glyphorder.ttx 2> glyphorder.log \
|| { echo error; exit 1; }
echo converting name table...
${BINDIR}/conv_name \
${SRC_FONTBASE} "${TOOLVER}" ${TTXDIR}/${SRC_FONTBASE}._n_a_m_e.ttx \
2> name.log | sed -f ${BASEDIR}/font_name.sed > name.ttx \
|| { echo error; exit 1; }
echo converting cmap table...
${BINDIR}/conv_cmap \
table.tbl ${TTXDIR}/${SRC_FONTBASE}._c_m_a_p.ttx \
> cmap.ttx 2> cmap.log \
|| { echo error; exit 1; }
echo converting CFF table...
${BINDIR}/conv_CFF \
table.tbl ${TTXDIR}/${SRC_FONTBASE}.C_F_F_.ttx \
2> CFF.log | sed -f ${BASEDIR}/font_name.sed > CFF.ttx \
|| { echo error; exit 1; }
if [ -f ${TTXDIR}/${SRC_FONTBASE}.G_D_E_F_.ttx ]; then
echo converting GDEF table...
${BINDIR}/conv_GDEF \
table.tbl ${TTXDIR}/${SRC_FONTBASE}.G_D_E_F_.ttx \
> GDEF.ttx 2> GDEF.log \
|| { echo error; exit 1; }
else
echo no GDEF table...
fi
echo converting GPOS table...
${BINDIR}/conv_GPOS \
table.tbl ${TTXDIR}/${SRC_FONTBASE}.G_P_O_S_.ttx \
> GPOS.ttx 2> GPOS.log \
|| { echo error; exit 1; }
echo converting GSUB table...
${BINDIR}/conv_GSUB \
table.tbl ${TTXDIR}/${SRC_FONTBASE}.G_S_U_B_.ttx \
> GSUB.ttx 2> GSUB.log \
|| { echo error; exit 1; }
echo converting VORG table...
${BINDIR}/conv_VORG \
table.tbl ${TTXDIR}/${SRC_FONTBASE}.V_O_R_G_.ttx \
> VORG.ttx 2> VORG.log \
|| { echo error; exit 1; }
echo converting hmtx table...
${BINDIR}/conv_mtx \
table.tbl ${TTXDIR}/${SRC_FONTBASE}._h_m_t_x.ttx \
> hmtx_conv.ttx 2> hmtx_conv.log \
|| { echo error; exit 1; }
echo fixing widths in hmtx table...
${BINDIR}/fix_hmtx \
table.tbl hmtx_conv.ttx \
> hmtx.ttx 2> hmtx.log \
|| { echo error; exit 1; }
echo converting vmtx table...
${BINDIR}/conv_mtx \
table.tbl ${TTXDIR}/${SRC_FONTBASE}._v_m_t_x.ttx \
> vmtx.ttx 2> vmtx.log \
|| { echo error; exit 1; }
echo making adjust table...
${SCRIPTDIR}/make_adjust.py \
table.tbl \
${TTXDIR}/${SRC_FONTBASE}._h_m_t_x.ttx hmtx.ttx \
> adjust.tbl 2> make_adjust.log \
|| { echo error; exit 1; }
mv -f CFF.ttx CFF_origin.ttx || { echo error; exit 1; }
echo adjusting CFF table...
${SCRIPTDIR}/adjust.py \
adjust.tbl \
CFF_origin.ttx \
CFF.ttx \
> adjust.log \
|| { echo error; exit 1; }
echo symbolic linking other tables...
ln -s ${TTXDIR}/${SRC_FONTBASE}._h_e_a_d.ttx || { echo error; exit 1; }
ln -s ${TTXDIR}/${SRC_FONTBASE}._h_h_e_a.ttx || { echo error; exit 1; }
ln -s ${TTXDIR}/${SRC_FONTBASE}._m_a_x_p.ttx || { echo error; exit 1; }
ln -s ${TTXDIR}/${SRC_FONTBASE}.O_S_2f_2.ttx || { echo error; exit 1; }
ln -s ${TTXDIR}/${SRC_FONTBASE}._p_o_s_t.ttx || { echo error; exit 1; }
ln -s ${TTXDIR}/${SRC_FONTBASE}.B_A_S_E_.ttx || { echo error; exit 1; }
ln -s ${TTXDIR}/${SRC_FONTBASE}._v_h_e_a.ttx || { echo error; exit 1; }
echo converting root ttx file...
sed -f ${BASEDIR}/font_tables.sed ${TTXDIR}/${SRC_FONTBASE}.ttx \
> output.ttx \
|| { echo error; exit 1; }
ttx -b --recalc-timestamp output.ttx \
|| { echo error; exit 1; }