yusukes@chromium.org | 9601aa9 | 2009-12-03 10:25:32 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) 2009 The Chromium 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 | |
| 7 | # Usage: ./test_unmalicious_fonts.sh [ttf_or_otf_file_name] |
| 8 | |
| 9 | BLACKLIST=./BLACKLIST.txt |
| 10 | CHECKER=./idempotent |
| 11 | |
| 12 | if [ ! -r "$BLACKLIST" ] ; then |
| 13 | echo "$BLACKLIST is not found." |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | if [ ! -x "$CHECKER" ] ; then |
| 18 | echo "$CHECKER is not found." |
| 19 | exit 1 |
| 20 | fi |
| 21 | |
| 22 | if [ $# -eq 0 ] ; then |
| 23 | # No font file is specified. Apply this script to all TT/OT files under the |
| 24 | # BASE_DIR below. |
| 25 | |
| 26 | # On Ubuntu Linux (>= 8.04), You can install ~1800 TrueType/OpenType fonts |
| 27 | # to /usr/share/fonts/truetype by: |
| 28 | # % sudo apt-get install ttf-.*[^0]$ |
| 29 | BASE_DIR=/usr/share/fonts/truetype/ |
| 30 | if [ ! -d $BASE_DIR ] ; then |
| 31 | # Mac OS X |
| 32 | BASE_DIR="/Library/Fonts/ /System/Library/Fonts/" |
| 33 | fi |
| 34 | # TODO(yusukes): Support Cygwin. |
| 35 | |
| 36 | # Recursively call this script. |
| 37 | find $BASE_DIR -type f -name '*tf' -exec "$0" {} \; |
| 38 | echo |
| 39 | exit 0 |
| 40 | fi |
| 41 | |
| 42 | if [ $# -gt 1 ] ; then |
| 43 | echo "Usage: $0 [ttf_or_otf_file_name]" |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
| 47 | # Check the font file using idempotent iff the font is not blacklisted. |
| 48 | base=`basename "$1"` |
| 49 | egrep -i -e "^$base" "$BLACKLIST" > /dev/null 2>&1 || "$CHECKER" "$1" > /dev/null 2>&1 || (echo ; echo "FAIL: $1 (Run $CHECKER $1 for more information.)") |
| 50 | echo -n "." |