3 dir=`mktemp --directory`
9 hb_shape="$hb_shape $@"
10 unicodes=`./hb-unicode-decode`
11 text=`./hb-unicode-encode "$unicodes"`
12 glyphs=`echo "$text" | $hb_shape "$fontfile"`
14 cp "$fontfile" "$dir/font.ttf"
19 if ! test -s "$dir/font.ttf.subset"; then
20 echo "Subsetter didn't produce nonempty subset font in $dir/font.ttf.subset" >&2
24 # Verify that subset font produces same glyphs!
25 glyphs_subset=`echo "$text" | $hb_shape "$dir/font.ttf.subset"`
27 if ! test "x$glyphs" = "x$glyphs_subset"; then
28 echo "Subset font produced different glyphs!" >&2
29 echo "Perhaps font doesn't have glyph names; checking visually..." >&2
30 hb_view=${hb_shape/shape/view}
31 echo "$text" | $hb_view "$dir/font.ttf" --output-format=png --output-file="$dir/orig.png"
32 echo "$text" | $hb_view "$dir/font.ttf.subset" --output-format=png --output-file="$dir/subset.png"
33 if ! cmp "$dir/orig.png" "$dir/subset.png"; then
34 echo "Images differ. Please inspect $dir/*.png." >&2
39 echo "Yep; all good." >&2
41 rm -f "$dir/subset.png"
45 sha1sum=`sha1sum "$dir/font.ttf.subset" | cut -d' ' -f1`
46 subset="fonts/sha1sum/$sha1sum.ttf"
47 mv "$dir/font.ttf.subset" "$subset"
49 echo "$subset:$unicodes:$glyphs"