1 #!/bin/sh 2 3 # Generate font binary files from font definitions. 4 # 5 # Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 6 # 7 # This program is free software; you can redistribute it and/or 8 # modify it under the terms of the GNU General Public License as 9 # published by the Free Software Foundation; either version 2 of 10 # the License, or (at your option) any later version. 11 # 12 # This program is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with this program; if not, write to the Free Software 19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 # Boston, MA 02110-1301, USA 21 22 THISDIR=$(dirname "$0") 23 DIRNAME=$(readlink -f "$THISDIR/..") 24 PROGNAME=$(basename "$0") 25 26 UNIFONT='/usr/share/unifont/unifont.hex' 27 28 if [ "$1" = '--help' ] ; then 29 cat 1>&2 <<EOF 30 Usage: $PROGNAME [ -q ] 31 32 Find font usage and generate the necessary binary font files. Currently, only 33 GNU Unifont is supported. 34 35 The optional -q argument indicates quiet execution, suppressing all output. 36 37 This script assumes that Unifont is installed in the following location: 38 39 $UNIFONT 40 41 The UNIFONT variable should be adjusted if this is not the case. 42 EOF 43 exit 1 44 fi 45 46 # Detect quiet operation. 47 48 if [ "$1" = '-q' ] ; then 49 QUIET="$1" 50 shift 1 51 else 52 QUIET= 53 fi 54 55 # Find all needed fonts and generate them. 56 57 for NEEDED in $(find "$DIRNAME/pkg" -name '*.tff.needed') ; do 58 TARGETDIR=$(dirname "$NEEDED") 59 FONTFILE=$(basename "$NEEDED" .needed) 60 FONTNAME=$(basename "$FONTFILE" .tff) 61 62 FONTPATH="$TARGETDIR/$FONTFILE" 63 64 if [ -e "$FONTPATH" ] ; then 65 if [ ! "$QUIET" ] ; then 66 echo "Exists, not generated: $FONTPATH" 1>&2 67 fi 68 continue 69 fi 70 71 if [ "$FONTNAME" != 'unifont' ] ; then 72 if [ ! "$QUIET" ] ; then 73 echo "Unrecognised ($FONTNAME), not generated: $FONTPATH" 1>&2 74 fi 75 continue 76 fi 77 78 if [ ! "$QUIET" ] ; then 79 echo "$FONTPATH" 80 fi 81 82 if ! "$THISDIR/readfont.py" "$UNIFONT" "$FONTPATH" ; then 83 cat 1>&2 <<EOF 84 85 Font generation halted due to conversion problem. Please check the UNIFONT 86 variable in this script, located here: 87 88 $DIRNAME/$PROGNAME 89 EOF 90 exit 1 91 fi 92 93 done 94 95 # vim: tabstop=4 expandtab shiftwidth=4