| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Run same operation using system FontForge version and built FontForge version |
| 4 | # and verify that the outputs are identical. Useful to perform regression testing |
| 5 | # on many fonts at once. |
| 6 | |
| 7 | FONT_LIST=fonts/PublicFontList.txt |
| 8 | FF_BIN_SYSTEM=/usr/local/bin/fontforge |
| 9 | FF_BIN_PROJECT=../build/bin/fontforge |
| 10 | |
| 11 | # Python commands to be executed for each tested SFD file. |
| 12 | # Arguments: |
| 13 | # argv[1] - input SFD file |
| 14 | # argv[2] - output file to be compared bytewise |
| 15 | FF_PY_SCRIPT_LINE="f=fontforge.open(argv[1]); f.save(argv[2])" |
| 16 | FF_OUTPUT_FILE="Output.sfd" |
| 17 | |
| 18 | # FF_PY_SCRIPT_LINE="f=fontforge.open(argv[1]); f.generate(argv[2], flags='no-FFTM-table')" |
| 19 | # FF_OUTPUT_FILE="Output.ttf" |
| 20 | |
| 21 | # FF_PY_SCRIPT_LINE="\ |
| 22 | # f=fontforge.open(argv[1]);\ |
| 23 | # f.generateFeatureFile('Out.fea')"$'\n'"\ |
| 24 | # for l in f.gsub_lookups: f.removeLookup(l)"$'\n'"\ |
| 25 | # for l in f.gpos_lookups: f.removeLookup(l)"$'\n'"\ |
| 26 | # f.mergeFeature('Out.fea'); f.save(argv[2])" |
| 27 | # FF_OUTPUT_FILE="Output.sfd" |
| 28 | |
| 29 | # # NOTE: Zeroize "CreationTime" and "ModificationTime" in SFD_DumpSplineFontMetadata() |
| 30 | # FF_PY_SCRIPT_LINE="\ |
| 31 | # f=fontforge.open(argv[1]);\ |
| 32 | # f.cidConvertByCmap('/home/iorsh/devel/cmap-resources/Adobe-Identity-0/CMap/Identity-H')"$'\n'"\ |
| 33 | # f.generateFeatureFile('Out.fea')"$'\n'"\ |
| 34 | # for l in f.gsub_lookups: f.removeLookup(l)"$'\n'"\ |
| 35 | # for l in f.gpos_lookups: f.removeLookup(l)"$'\n'"\ |
| 36 | # f.mergeFeature('Out.fea'); f.save(argv[2])" |
| 37 | # FF_OUTPUT_FILE="Output.sfd" |
| 38 | |
| 39 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) |
| 40 | FF_BIN_PROJECT=$SCRIPT_DIR/$FF_BIN_PROJECT |
| 41 | |
| 42 | cat $FONT_LIST | |
| 43 | while read font_url; do |
| 44 | failure=0 |
| 45 | TMP_DIR_SYS=`mktemp -d` |
| 46 | pushd $TMP_DIR_SYS > /dev/null |
| 47 | if (wget -q --timeout=60 $font_url); then |
| 48 | SFD_FILE=`ls` |
| 49 | TMP_DIR_PROJ=`mktemp -d` |
| 50 | cp $SFD_FILE $TMP_DIR_PROJ |
| 51 | |
| 52 | # Execute system FontForge binary |
| 53 | $FF_BIN_SYSTEM -c "$FF_PY_SCRIPT_LINE" $SFD_FILE $FF_OUTPUT_FILE >/dev/null 2>&1 |
| 54 | |
| 55 | # Execute compiled project FontForge binary |
| 56 | pushd $TMP_DIR_PROJ > /dev/null |
| 57 | $FF_BIN_PROJECT -c "$FF_PY_SCRIPT_LINE" $SFD_FILE $FF_OUTPUT_FILE >/dev/null 2>&1 |
| 58 | popd > /dev/null |
| 59 | |
| 60 | if [ ! -f $TMP_DIR_SYS/$FF_OUTPUT_FILE ] && [ ! -f $TMP_DIR_PROJ/$FF_OUTPUT_FILE ]; then |
| 61 | echo "\e[0;33mNO OUTPUT\e[0m: $font_url" |
| 62 | failure=1 |
| 63 | elif (cmp --quiet $TMP_DIR_SYS/$FF_OUTPUT_FILE $TMP_DIR_PROJ/$FF_OUTPUT_FILE); then |
| 64 | echo "PASS: $font_url" |
| 65 | else |
| 66 | echo -e "\e[0;31mFAIL\e[0m: $font_url" |
| 67 | failure=1 |
| 68 | fi |
| 69 | |
| 70 | if [ $failure -eq 0 ]; then |
| 71 | rm -rf $TMP_DIR_PROJ |
| 72 | else |
| 73 | echo " Project output: $TMP_DIR_PROJ" |
| 74 | fi |
| 75 | else |
| 76 | echo "SKIP: $font_url" |
| 77 | fi |
| 78 | popd > /dev/null |
| 79 | if [ $failure -eq 0 ]; then |
| 80 | rm -rf $TMP_DIR_SYS |
| 81 | else |
| 82 | echo " System output: $TMP_DIR_SYS" |
| 83 | fi |
| 84 | done |