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