Imported Upstream version 1.7.6
[platform/upstream/harfbuzz.git] / test / shaping / record-test.sh
index cf17c54..f31d30b 100755 (executable)
@@ -1,7 +1,12 @@
 #!/bin/bash
 
-dir=`mktemp --directory`
+dir=`mktemp -d`
 
+out=/dev/stdout
+if test "x${1:0:3}" == 'x-o='; then
+       out=${1:3}
+       shift
+fi
 hb_shape=$1
 shift
 fontfile=$1
@@ -11,7 +16,7 @@ if test "x${fontfile:0:1}" == 'x-'; then
 fi
 shift
 if ! echo "$hb_shape" | grep -q 'hb-shape'; then
-       echo "Specify hb-shape (not hb-view, etc)." >&2
+       echo "Specify hb-shape (not hb-view, etc): got "$hb_shape"." >&2
        exit 1
 fi
 options=
@@ -41,12 +46,15 @@ if test $? != 0; then
        echo "hb-shape failed." >&2
        exit 2
 fi
+glyph_names=`echo "$text" | $hb_shape $options --no-clusters --no-positions "$fontfile" | sed 's/[][]//g; s/|/,/g'`
 
 cp "$fontfile" "$dir/font.ttf"
-pyftsubset \
+fonttools subset \
        --glyph-names \
        --no-hinting \
+       --layout-features='*' \
        "$dir/font.ttf" \
+       --glyphs="$glyph_names" \
        --text="$text"
 if ! test -s "$dir/font.subset.ttf"; then
        echo "Subsetter didn't produce nonempty subset font in $dir/font.subset.ttf" >&2
@@ -64,8 +72,8 @@ if ! test "x$glyphs" = "x$glyphs_subset"; then
        echo "$text" | $hb_view $options "$dir/font.subset.ttf" --output-format=png --output-file="$dir/subset.png"
        if ! cmp "$dir/orig.png" "$dir/subset.png"; then
                echo "Images differ.  Please inspect $dir/*.png." >&2
-               echo "$glyphs"
-               echo "$glyphs_subset"
+               echo "$glyphs" >> "$out"
+               echo "$glyphs_subset" >> "$out"
                exit 2
        fi
        echo "Yep; all good." >&2
@@ -75,7 +83,7 @@ if ! test "x$glyphs" = "x$glyphs_subset"; then
 fi
 
 sha1sum=`sha1sum "$dir/font.subset.ttf" | cut -d' ' -f1`
-subset="fonts/sha1sum/$sha1sum.ttf"
+subset="data/in-house/fonts/$sha1sum.ttf"
 mv "$dir/font.subset.ttf" "$subset"
 
 # There ought to be an easier way to do this, but it escapes me...
@@ -86,8 +94,12 @@ echo "$glyphs" > "$glyphs_file"
 # Open the "file"s
 exec 3<"$unicodes_file"
 exec 4<"$glyphs_file"
+relative_subset="$subset"
+if test "$out" != "/dev/stdout"; then
+       relative_subset="$(/usr/bin/python -c 'import os, sys; print (os.path.relpath (sys.argv[1], sys.argv[2]))' "$subset" "$(dirname "$out")")"
+fi
 while read uline <&3 && read gline <&4; do
-       echo "$subset:$options:$uline:$gline"
+       echo "$relative_subset:$options:$uline:$gline" >> "$out"
 done