paul@16 | 1 | #!/bin/sh |
paul@16 | 2 | |
paul@16 | 3 | if ! which realpath > /dev/null ; then |
paul@16 | 4 | echo "Please install the realpath program." 1>&2 |
paul@16 | 5 | exit 1 |
paul@16 | 6 | fi |
paul@16 | 7 | |
paul@16 | 8 | THISDIR=`dirname "$0"` |
paul@16 | 9 | DIRNAME=`realpath "$THISDIR/.."` |
paul@16 | 10 | PROGNAME=`basename "$0"` |
paul@16 | 11 | |
paul@16 | 12 | UNIFONT='/usr/share/unifont/unifont.hex' |
paul@16 | 13 | |
paul@16 | 14 | if [ "$1" = '--help' ] ; then |
paul@16 | 15 | cat 1>&2 <<EOF |
paul@16 | 16 | Usage: $PROGNAME [ -q ] |
paul@16 | 17 | |
paul@16 | 18 | Find font usage and generate the necessary binary font files. Currently, only |
paul@16 | 19 | GNU Unifont is supported. |
paul@16 | 20 | |
paul@16 | 21 | The optional -q argument indicates quiet execution, suppressing all output. |
paul@27 | 22 | |
paul@27 | 23 | This script assumes that Unifont is installed in the following location: |
paul@27 | 24 | |
paul@27 | 25 | $UNIFONT |
paul@27 | 26 | |
paul@27 | 27 | The UNIFONT variable should be adjusted if this is not the case. |
paul@16 | 28 | EOF |
paul@16 | 29 | exit 1 |
paul@16 | 30 | fi |
paul@16 | 31 | |
paul@16 | 32 | # Detect quiet operation. |
paul@16 | 33 | |
paul@16 | 34 | if [ "$1" = '-q' ] ; then |
paul@16 | 35 | QUIET="$1" |
paul@16 | 36 | shift 1 |
paul@16 | 37 | else |
paul@16 | 38 | QUIET= |
paul@16 | 39 | fi |
paul@16 | 40 | |
paul@16 | 41 | # Find all needed fonts and generate them. |
paul@16 | 42 | |
paul@16 | 43 | for NEEDED in `find "$DIRNAME/pkg" -name '*.tff.needed'` ; do |
paul@16 | 44 | TARGETDIR=`dirname "$NEEDED"` |
paul@16 | 45 | FONTFILE=`basename "$NEEDED" .needed` |
paul@16 | 46 | FONTNAME=`basename "$FONTFILE" .tff` |
paul@16 | 47 | |
paul@16 | 48 | FONTPATH="$TARGETDIR/$FONTFILE" |
paul@16 | 49 | |
paul@16 | 50 | if [ -e "$FONTPATH" ] ; then |
paul@16 | 51 | if [ ! "$QUIET" ] ; then |
paul@16 | 52 | echo "Exists, not generated: $FONTPATH" 1>&2 |
paul@16 | 53 | fi |
paul@16 | 54 | continue |
paul@16 | 55 | fi |
paul@16 | 56 | |
paul@16 | 57 | if [ "$FONTNAME" != 'unifont' ] ; then |
paul@16 | 58 | if [ ! "$QUIET" ] ; then |
paul@16 | 59 | echo "Unrecognised ($FONTNAME), not generated: $FONTPATH" 1>&2 |
paul@16 | 60 | fi |
paul@16 | 61 | continue |
paul@16 | 62 | fi |
paul@16 | 63 | |
paul@16 | 64 | if [ ! "$QUIET" ] ; then |
paul@16 | 65 | echo "$FONTPATH" |
paul@16 | 66 | fi |
paul@27 | 67 | |
paul@27 | 68 | if ! "$THISDIR/readfont.py" "$UNIFONT" "$FONTPATH" ; then |
paul@27 | 69 | cat 1>&2 <<EOF |
paul@27 | 70 | |
paul@27 | 71 | Font generation halted due to conversion problem. Please check the UNIFONT |
paul@27 | 72 | variable in this script, located here: |
paul@27 | 73 | |
paul@27 | 74 | $DIRNAME/$PROGNAME |
paul@27 | 75 | EOF |
paul@27 | 76 | exit 1 |
paul@27 | 77 | fi |
paul@27 | 78 | |
paul@16 | 79 | done |