3 # Copyright 2000 Peter Ganten
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 if [ -f `which mktemp` ]; then
23 TFILE=`mktemp -q /tmp/fconv.XXXXXX`
28 # Where the fnt2bdf utility resides
30 if [ -z "$FC" ]; then FC=$HOME""/wine/tools/fnt2bdf; fi;
32 # which OEM_CHARSET to use
34 TARGET=/usr/X11R6/lib/X11/fonts/misc;
35 BDFTOPCF=/usr/X11R6/bin/bdftopcf;
41 echo "usage: "`basename $0`" [-q] [-c charset] [-t fontdir] [-b bdftopcf] [-f fnt2bdf]"
42 echo " [-p pattern] windir"
44 echo "this utility scans a directory and its subdirectories for bitmap-fonts"
45 echo "in Windows format, converts them to PCF-fons and installs them. If X"
46 echo "is running, the X fontpath is re-adjusted."
49 echo " -q quit operation."
50 echo " -c charset charset name for OEM_CHARSET fonts, default: $CHARSET"
51 echo " -t fontdir directory to install the converted fonts in. This"
52 echo " directory should be a known fontdirectory to X, default:"
54 echo " -b bdftopcf name of the program to call for bdf to pcf conversion,"
55 echo " default: $BDFTOPCF";
56 echo " -f fnt2bdf name of the program to call for winfont to bdf conversion,"
58 echo " -p pattern Shell-Pattern of the filenames to look for. By default, the"
59 echo " utility will look for the pattern "$PAT" (case insensitive)."
60 echo " windir base directory to search."
67 -c ) shift; if [ "$1" ]; then CHARSET=$1; shift; else usage; fi; ;;
68 -t ) shift; if [ "$1" ]; then TARGET=$1; shift; else usage; fi; ;;
69 -b ) shift; if [ "$1" ]; then BDFTOPCF=$1; shift; else usage; fi; ;;
70 -f ) shift; if [ "$1" ]; then FC=$1; shift; else usage; fi; ;;
71 -p ) shift; if [ "$1" ]; then PAT=$1; shift; else usage; fi; ;;
74 * ) if [ "$WIND" ]; then usage; else WIND=$1; shift; fi; ;;
78 if [ ! "$WIND" ]; then usage; fi;
79 if [ ! -d "$WIND" ]; then $Q echo "$WIND is not a directory"; exit 1; fi;
80 if [ ! -d "$TARGET" ]; then $Q echo "$TARGET is not a directory"; exit 1; fi;
81 type -p $BDFTOPCF 1>/dev/null || { $Q echo "Can 't execute $BDFTOPCF"; exit 1; }
82 type -p $FC 1>/dev/null || { $Q echo "Can't execute $FC"; exit 1; }
84 $Q echo -n "looking for bitmap fonts (\"$PAT\") in directory \"$WIND\"... ";
85 FONTS=`find $WIND -iname "$PAT" 1>$TFILE 2>/dev/null`;
87 $Q echo "$PAT is an invalid search expression"; exit 1;
91 { while read dummy; do FONTS[$i]="$dummy"; i=$[$i+1]; done; } < $TFILE
95 if [ -z "$FONTS" ]; then $Q echo "Can't find any fonts in $WIND"; exit 1; fi;
98 for i in "${FONTS[@]}"; do cp $i $TMPDIR; done
101 for i in "${FONTS[@]}"; do
102 FNT=`basename "$i"`; FNT=${FNT%.???};
103 $Q echo "converting $i";
105 $FC -c $CHARSET -f $FNT "$i" 2>/dev/null;
107 $FC -c $CHARSET -f $FNT "$i";
112 if [ "$i" = "*.bdf" ]; then
113 echo "No fonts extracted"; rm -rf "$TMPDIR"; exit 0;
115 bdftopcf "$i" | gzip -c > ${i%.???}.pcf.gz;
116 $Q echo "installing ${i%.???}.pcfi.gz";
117 mv "${i%.???}.pcf.gz" $TARGET 2>/dev/null
118 if [ $? -ne 0 ]; then
119 $Q echo "Can't install fonts to $TARGET. Try again as the root user.";
120 $Q echo "Cleaning up..."; cd "$OLDPWD"; rm -rf "$TMPDIR"; exit 1;
126 $Q echo "running mkfontdir";
128 mkfontdir 1>/dev/null 2>/dev/null;
134 if [ "$DISPLAY" ]; then $Q echo "adjusting X font database"; xset fp rehash; fi;