1#!/bin/sh 2 3# Copyright (c) 2009-2017 The OTS Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7test "x$top_srcdir" = x && top_srcdir=. 8test "x$top_builddir" = x && top_builddir=. 9 10# Usage: ./test_good_fonts.sh [ttf_or_otf_file_name] 11 12BASE_DIR=$top_srcdir/tests/fonts/good/ 13BLOCKLIST=$top_srcdir/tests/BLOCKLIST.txt 14CHECKER=$top_builddir/ots-idempotent$EXEEXT 15 16if [ ! -r "$BLOCKLIST" ] ; then 17 echo "$BLOCKLIST is not found." 18 exit 1 19fi 20 21if [ ! -x "$CHECKER" ] ; then 22 echo "$CHECKER is not found." 23 exit 1 24fi 25 26if [ $# -eq 0 ] ; then 27 # No font file is specified. Apply this script to all TT/OT files we can find 28 # on the system. 29 30 if [ ! -d "$BASE_DIR" ] ; then 31 echo "$BASE_DIR does not exist." 32 exit 1 33 fi 34 35 if [ x"$FONTS" = x ]; 36 then 37 # Mac OS X 38 FONTS=$"$FONTS"$'\n'"$(find /System/Library/Fonts/ -type f -name '*tf' -o -name '*tc')" 39 fi 40 41 42 if [ x"$FONTS" = x ] && $(command fc-list &>/dev/null); 43 then 44 echo $FONTS 45 CFF=$(fc-list --format="%{file}\n" :fontformat=CFF | sort -u) 46 TTF=$(fc-list --format="%{file}\n" :fontformat=TrueType | sort -u) 47 FONTS="$FONTS"$'\n'"$CFF"$'\n'"$TTF" 48 fi 49 50 FONTS="$FONTS"$'\n'"$(find $BASE_DIR -type f)" 51 52 # Recursively call this script. 53 FAILS=0 54 IFS=$'\n' 55 for f in $FONTS; do 56 if [[ $f == *.dfont ]]; then continue; fi # Ignore .dfont’s 57 $0 "$f" 58 FAILS=$((FAILS+$?)) 59 done 60 61 if [ $FAILS != 0 ]; then 62 echo "$FAILS fonts failed." 63 exit 1 64 else 65 echo "All fonts passed" 66 exit 0 67 fi 68fi 69 70if [ $# -gt 1 ] ; then 71 echo "Usage: $0 [ttf_or_otf_file_name]" 72 exit 1 73fi 74 75# Check the font file using idempotent if the font is not blacklisted. 76BASE=`basename "$1"` 77SKIP=`egrep -i -e "^$BASE" "$BLOCKLIST"` 78 79if [ "x$SKIP" = "x" ]; then 80 $CHECKER "$1" 81 RET=$? 82 if [ $RET != 0 ]; then 83 echo "FAILED: $1" 84 else 85 echo "PASSED: $1" 86 fi 87 exit $RET 88fi 89