-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata.bash
executable file
·180 lines (155 loc) · 5.8 KB
/
metadata.bash
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
#!/bin/bash
export orya="../../../../orya/fonts/asika/source"
export deva="../../../../deva/fonts/panini/source"
export knda="../../../../knda/fonts/badami/source"
export taml="../../../../taml/fonts/thiruvalluvar/source"
locl=${PWD/ci\//}-local
dev=$locl/dev
rc=$dev/smithrc
source $rc
# Convert to friendly working glyph names
pushd ${src}
for sfd in *-???*.sfd
do
echo $sfd
perl $HOME/script/zind/bin/codepoint2name.pl -c $sfd -n tmp.sfd -m $HOME/script/zind/fonts/indictable.tsv
mv tmp.sfd $sfd
done
popd
# Convert SFD to UFO
pushd ${src}
rm -rf *.ufo
for sfd in *-???*.sfd
do
echo $sfd
fontfilename="$(basename $sfd .sfd)"
fontforge -script ${nlci}/sfd2ufo.ff $sfd ${fontfilename}.ufo3
mv -v ${fontfilename}.ufo3 ${fontfilename}.ufo
# Set WOFF metadata in UFOs
# Used to be also needed to work around https://github.com/fontforge/fontforge/issues/4951
fontinfo=${fontfilename}.ufo/fontinfo.plist
head -n -2 ${fontinfo} > tmp.plist
mv tmp.plist ${fontinfo}
cat ${nlci}/fontinfo1.plist >> ${fontinfo}
echo -n "<string>" >> ${fontinfo}
echo -n $(grep "Pan " ../FONTLOG.txt) >> ${fontinfo}
echo "</string>" >> ${fontinfo}
cat ${nlci}/fontinfo2.plist >> ${fontinfo}
done
popd
# Initial modifications to the UFOs
for ufo in ${src}/*.ufo
do
echo "setting metrics in UFO ${ufo}"
psfnormalize -p backup=0 -v 3 -p checkfix=none $ufo
${nlci}/reverse-fix-direction.py $ufo init
./tools/encoding.py $ufo
${nlci}/heights.py $ufo
${nlci}/line_spacing.py $ufo
if [ -f ${src}/delete_latin_glyphs.txt ]
then
echo "deleting latin glyphs (to be re-added later) in UFO ${ufo}"
psfdeleteglyphs -i ${src}/delete_latin_glyphs.txt $ufo
fi
# Save needed anchors
$HOME/script/tools/anchor-keep.py mark $nlci/anchors.json $ufo
echo "Use script specific dashes"
psfbuildcompgc -i ${src}/composites.glyphConstruction $ufo
done
# Add many Latin glyphs to the UFOs
pushd ${cs}
cat main_import.txt nlci-latin.txt cp1252_nf?.txt > all_import.txt
cat main_import.txt nlci-latin.txt cp1252_nfc.txt > nfc_import.txt
cat main_import.txt nlci-latin.txt cp1252_nfd.txt > nfd_import.txt
popd
cat $HOME/script/smithplus/etc/glyph_names/glyph_names.csv ${nlci}/glyphsapp_override.csv > ${nlci}/glyph_names.csv
rm -rf ${src}/copyglyphs
mkdir ${src}/copyglyphs
export PYTHONPATH=${nlci}
./addchars.py ${src} ${nlci} ${cs}
# Further modifications to the UFOs using face and style names
pushd ${src}
for fi in ${!faces[@]} # loop over indices
do
f=${faces[$fi]} # fi is the index into the array faces
for si in ${!styles[@]} # loop over indices
do
s=${styles[$si]} # si is the index into the array styles
ufo=${f/ /}-${s/ /}.ufo # remove spaces in both face and style strings
# Restore needed anchors
$HOME/script/tools/anchor-keep.py only $nlci/anchors.json $ufo
# Remove dangling composites
composites -c $ufo
# Swap Latin and Indic specific punctuation (and digits)
${nlci}/indic_punct.py $ufo
# fix issues found by Font Bakery
${nlci}/fix-spaces.py $ufo
${nlci}/fix-gdef.py $ufo
echo "setting family ${f} and style ${s} in UFO ${ufo}"
psfsetkeys -p backup=0 -k familyName -v "${f}" $ufo
psfsetkeys -p backup=0 -k openTypeNamePreferredFamilyName -v "${f}" $ufo
psfsetkeys -p backup=0 -k styleName -v "${s}" $ufo
psfsetkeys -p backup=0 -k openTypeNamePreferredSubfamilyName -v "${s}" $ufo
psfsetkeys -p backup=0 -k postscriptFullName -v "${f} ${s}" $ufo
psfsetkeys -p backup=0 -k styleMapFamilyName -v "${f}" $ufo
psfsetkeys -p backup=0 -k styleMapStyleName -v "${s,,}" $ufo
echo "setting general keys in UFO ${ufo}"
psfsetkeys -p backup=0 -i ${nlci}/fontinfo.csv -k "openTypeNameDescription" -v "$desc_long" $ufo
psfsetkeys -p backup=0 -i ${nlci}/lib.csv --plist lib $ufo
echo "setting glyphsapp keys in UFO ${ufo}"
if [ "$s" = "Bold" -o "$s" = "Bold Italic" ]
then
psfsetkeys -p backup=0 -k "com.schriftgestaltung.weight" -v "Bold" --plist lib $ufo
psfsetkeys -p backup=0 -k "com.schriftgestaltung.weightValue" -v "700" --plist lib $ufo
else
psfsetkeys -p backup=0 -k "com.schriftgestaltung.weightValue" -v "400" --plist lib $ufo
fi
if [ "$s" = "Italic" -o "$s" = "Bold Italic" ]
then
echo "fixing italicAngle in UFO ${ufo}"
psfsetkeys -p backup=0 -k "italicAngle" -v "-12" $ufo
fi
echo "importing glyphs in UFO ${ufo}"
../tools/import.bash "${f}" "${s/ /}" $ufo
if [ -f rename-${f}.csv ]
then
echo "renaming glyphs in UFO ${ufo}"
psfrenameglyphs -i rename-${f}.csv $ufo
fi
if [ -f composites.txt ]
then
echo "building composites in UFO ${ufo}"
psfbuildcomp -c -f -i composites.txt $ufo
fi
# echo "polishing glyphs in UFO ${ufo}"
${nlci}/polish.py $ufo
if [ -x ../tools/cleanup.py ]
then
echo "fixing glyphs in UFO ${ufo}"
../tools/cleanup.py $ufo
fi
if [ -x ../tools/anchors.bash ]
then
echo "Preparing to add (adjust) anchors in UFO ${ufo}"
../tools/anchors.bash $ufo
fi
if [ -x ../tools/anchors.py ]
then
../tools/anchors.py $ufo
fi
if [ "$s" = "Regular" ]
then
echo "listing glyphs in UFO ${ufo}"
gdcsv
fi
done
done
popd
if [ -x ./tools/syncanchors ]
then
./tools/syncanchors
fi
echo "now running preflight"
./preflight
echo "done running preflight"
echo "done producing UFO sources"