winex11: Implement a BlendImage entry point in the XRender driver.
[wine.git] / tools / font_convert.sh
blob91ca6003bd3d40eb3f2059ef9fb8284345d22f52
1 #! /bin/bash
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 # default settings
21 TMPDIR=/tmp/fconv.$$;
22 if [ -f `which mktemp` ]; then
23 TFILE=`mktemp -q /tmp/fconv.XXXXXX`
24 else
25 TFILE=`tempfile`;
28 # Where the fnt2bdf utility resides
29 FC=`which fnt2bdf`;
30 if [ -z "$FC" ]; then FC=$HOME""/wine/tools/fnt2bdf; fi;
32 # which OEM_CHARSET to use
33 CHARSET="winsys";
34 TARGET=/usr/X11R6/lib/X11/fonts/misc;
35 BDFTOPCF=/usr/X11R6/bin/bdftopcf;
36 PAT="*.fon";
37 Q="";
38 OLDPWD=`pwd`;
40 usage () {
41 echo "usage: "`basename $0`" [-q] [-c charset] [-t fontdir] [-b bdftopcf] [-f fnt2bdf]"
42 echo " [-p pattern] windir"
43 echo
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."
47 echo
48 echo "options:"
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:"
53 echo " $TARGET";
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,"
57 echo " default: $FC"
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."
61 exit 1;
65 while [ "$1" ]; do
66 case $1 in
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; ;;
72 -q ) shift; Q=":"; ;;
73 -* ) usage; ;;
74 * ) if [ "$WIND" ]; then usage; else WIND=$1; shift; fi; ;;
75 esac;
76 done;
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`;
86 if [ $? -ne 0 ]; then
87 $Q echo "$PAT is an invalid search expression"; exit 1;
88 fi;
89 i=0;
91 { while read dummy; do FONTS[$i]="$dummy"; i=$[$i+1]; done; } < $TFILE
92 rm $TFILE;
93 $Q echo "done."
95 if [ -z "$FONTS" ]; then $Q echo "Can't find any fonts in $WIND"; exit 1; fi;
97 mkdir "$TMPDIR"
98 for i in "${FONTS[@]}"; do cp $i $TMPDIR; done
99 cd "$TMPDIR"
101 for i in "${FONTS[@]}"; do
102 FNT=`basename "$i"`; FNT=${FNT%.???};
103 $Q echo "converting $i";
104 if [ "$Q" ]; then
105 $FC -c $CHARSET -f $FNT "$i" 2>/dev/null;
106 else
107 $FC -c $CHARSET -f $FNT "$i";
109 done;
111 for i in *.bdf; do
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;
122 rm "$i";
123 done;
125 cd $TARGET;
126 $Q echo "running mkfontdir";
127 if [ "$Q" ]; then
128 mkfontdir 1>/dev/null 2>/dev/null;
129 else
130 mkfontdir
132 rm -rf "$TMPDIR"
134 if [ "$DISPLAY" ]; then $Q echo "adjusting X font database"; xset fp rehash; fi;