File: ttdiff.sh

package info (click to toggle)
fonts-hack 3.003-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,564 kB
  • sloc: sh: 811; python: 129; makefile: 34; xml: 30
file content (50 lines) | stat: -rw-r--r-- 1,172 bytes parent folder | download | duplicates (3)
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
#!/bin/bash

# Copyright 2018 Source Foundry Authors
# MIT License

# compare fonts with ttx
ttdiff () {
    if [ "$#" -lt 2 ]
    then
        echo "Usage: ttdiff FONT1.ttf FONT2.ttf [tables ...]"
        return 1
    fi
    first="$1"
    if [ ! -f "$first" ]; then
        echo "File $first not found"
        return 1
    fi
    second="$2"
    if [ ! -f "$second" ]; then
        echo "File $second not found"
        return 1
    fi
    tables=""
    for i in ${@:3}
    do
        if [ ! -z "$i" ]
        then
            table="-t "
            if [ ${#i} -eq 3 ]; then
                # add trailing space to pad tag to four chars
                table+="'"$i" '"
            else
                table+=$i
            fi
            tables+="$table "
        fi
    done
    cmd1="ttx -q -o - $tables \"$first\" 2>/dev/null"
    cmd2="ttx -q -o - $tables \"$second\" 2>/dev/null"
    echo $cmd1
    echo $cmd2
    # colorize output if colordiff is installed
    if `command -v colordiff >/dev/null 2>&1`; then
        diff -u <(eval $cmd1) <(eval $cmd2) | colordiff | less -R
    else
        diff -u <(eval $cmd1) <(eval $cmd2) | less -R
    fi
}

ttdiff "$@"