diff options
author | Rasmus Andersson <rasmus@notion.se> | 2018-09-01 08:21:09 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2018-09-01 08:21:09 +0300 |
commit | ca1cb8c942f01b8b70bf344c00d770c4867dfc32 (patch) | |
tree | dd4742fe880b1198c431c1a82c0f7c4274a7d04f /misc/kerndiff/kerndiff.sh | |
parent | 6688a81405b8c234f6b197f5779533e801911404 (diff) | |
download | inter-ca1cb8c942f01b8b70bf344c00d770c4867dfc32.tar.xz |
tooling
Diffstat (limited to 'misc/kerndiff/kerndiff.sh')
-rwxr-xr-x | misc/kerndiff/kerndiff.sh | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/misc/kerndiff/kerndiff.sh b/misc/kerndiff/kerndiff.sh new file mode 100755 index 000000000..64ce8c2f1 --- /dev/null +++ b/misc/kerndiff/kerndiff.sh @@ -0,0 +1,96 @@ +#!/bin/bash -e + +function usage() { + cat 1>&2 <<__END +usage: $0 [options] <font1> <font2> +options: + -h, --help Show usage and exit + Rest of options are forwarded to the "diff" program +__END +} + +diffargs=() +file1= +file2= + +while [ "$1" != "" ]; do + PARAM=`echo $1 | awk -F= '{print $1}'` + VALUE=`echo $1 | awk -F= '{print $2}'` + case $PARAM in + -h | -help | --help) + usage + exit + ;; + -*) + diffargs[${#diffargs[*]}]=$1 + ;; + *) + if [[ "$file1" == "" ]]; then + file1=$PARAM + elif [[ "$file2" == "" ]]; then + file2=$PARAM + else + echo "Too many files" 1>&2 + exit 1 + fi + ;; + esac + shift +done + +if [[ "$file1" == "" ]] && [[ "$file2" == "" ]]; then + usage + exit 1 +elif [[ "$file1" == "" ]] || [[ "$file2" == "" ]]; then + echo "Not enough files" 1>&2 + exit 1 +fi + +tmpdir=$TMPDIR +if [[ "$tmpdir" == "" ]]; then + tmpdir=/tmp +fi +tmpdir=$tmpdir/kerndiff-tmp +mkdir -p "$tmpdir" + +file1x="$(basename "$file1")" +file2x="$(basename "$file2")" + +pushd "$(dirname "$0")" >/dev/null +KERNDIFF_DIR=$PWD +popd >/dev/null + +case $file1 in + *.otf) + python "$KERNDIFF_DIR/getKerningPairsFromOTF.py" "$file1" \ + > "$tmpdir/$file1x" + ;; + *.ufo) + python "$KERNDIFF_DIR/getKerningPairsFromUFO.py" "$file1" \ + > "$tmpdir/$file1x" + ;; + *) + echo "unsupported file format: $file1" + exit 1 + ;; +esac + +case $file2 in + *.otf) + python "$KERNDIFF_DIR/getKerningPairsFromOTF.py" "$file2" \ + > "$tmpdir/$file2x" + ;; + *.ufo) + python "$KERNDIFF_DIR/getKerningPairsFromUFO.py" "$file2" \ + > "$tmpdir/$file2x" + ;; + *) + echo "unsupported file format: $file2" + exit 1 + ;; +esac + +pushd $tmpdir >/dev/null +diff -u "${diffargs[@]}" "$file1x" "$file2x" +popd >/dev/null +rm -rf "$tmpdir" |