d3d9: Add visual test for D3DRS_SHADEMODE states.
[wine] / tools / font_convert.sh
CommitLineData
0ea83643 1#! /bin/bash
0799c1a7
AJ
2#
3# Copyright 2000 Peter Ganten
4#
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.
9#
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.
14#
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
360a3f91 17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
0799c1a7 18#
0ea83643
PG
19
20# default settings
21TMPDIR=/tmp/fconv.$$;
cd7534e8
JG
22if [ -f `which mktemp` ]; then
23 TFILE=`mktemp -q /tmp/fconv.XXXXXX`
24else
25 TFILE=`tempfile`;
26fi
0ea83643 27
7cae558b 28# Where the fnt2bdf utility resides
cd7534e8
JG
29FC=`which fnt2bdf`;
30if [ -z "$FC" ]; then FC=$HOME""/wine/tools/fnt2bdf; fi;
31
0ea83643
PG
32# which OEM_CHARSET to use
33CHARSET="winsys";
34TARGET=/usr/X11R6/lib/X11/fonts/misc;
35BDFTOPCF=/usr/X11R6/bin/bdftopcf;
36PAT="*.fon";
37Q="";
7cae558b 38OLDPWD=`pwd`;
0ea83643
PG
39
40usage () {
41 echo "usage: "`basename $0`" [-q] [-c charset] [-t fontdir] [-b bdftopcf] [-f fnt2bdf]"
42 echo " [-p pattern] windir"
7cae558b 43 echo
0ea83643
PG
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."
7cae558b 47 echo
0ea83643
PG
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;
62}
63
64
65while [ "$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; ;;
7cae558b 74 * ) if [ "$WIND" ]; then usage; else WIND=$1; shift; fi; ;;
0ea83643
PG
75 esac;
76done;
77
78if [ ! "$WIND" ]; then usage; fi;
79if [ ! -d "$WIND" ]; then $Q echo "$WIND is not a directory"; exit 1; fi;
80if [ ! -d "$TARGET" ]; then $Q echo "$TARGET is not a directory"; exit 1; fi;
81type -p $BDFTOPCF 1>/dev/null || { $Q echo "Can 't execute $BDFTOPCF"; exit 1; }
82type -p $FC 1>/dev/null || { $Q echo "Can't execute $FC"; exit 1; }
83
cd7534e8
JG
84$Q echo -n "looking for bitmap fonts (\"$PAT\") in directory \"$WIND\"... ";
85FONTS=`find $WIND -iname "$PAT" 1>$TFILE 2>/dev/null`;
7cae558b 86if [ $? -ne 0 ]; then
93416cda 87 $Q echo "$PAT is an invalid search expression"; exit 1;
0ea83643
PG
88fi;
89i=0;
cd7534e8 90
0ea83643
PG
91{ while read dummy; do FONTS[$i]="$dummy"; i=$[$i+1]; done; } < $TFILE
92rm $TFILE;
93$Q echo "done."
94
7cae558b 95if [ -z "$FONTS" ]; then $Q echo "Can't find any fonts in $WIND"; exit 1; fi;
0ea83643 96
8c2e573f 97mkdir "$TMPDIR"
cd7534e8 98for i in "${FONTS[@]}"; do cp $i $TMPDIR; done
8c2e573f 99cd "$TMPDIR"
0ea83643 100
7cae558b 101for i in "${FONTS[@]}"; do
0ea83643
PG
102 FNT=`basename "$i"`; FNT=${FNT%.???};
103 $Q echo "converting $i";
7cae558b 104 if [ "$Q" ]; then
0ea83643
PG
105 $FC -c $CHARSET -f $FNT "$i" 2>/dev/null;
106 else
107 $FC -c $CHARSET -f $FNT "$i";
108 fi;
109done;
110
111for i in *.bdf; do
4e422766 112 if [ "$i" = "*.bdf" ]; then
cd7534e8
JG
113 echo "No fonts extracted"; rm -rf "$TMPDIR"; exit 0;
114 fi;
115 bdftopcf "$i" | gzip -c > ${i%.???}.pcf.gz;
116 $Q echo "installing ${i%.???}.pcfi.gz";
117 mv "${i%.???}.pcf.gz" $TARGET 2>/dev/null
7cae558b 118 if [ $? -ne 0 ]; then
cd7534e8
JG
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;
121 fi;
0ea83643
PG
122 rm "$i";
123done;
124
125cd $TARGET;
7cae558b 126$Q echo "running mkfontdir";
0ea83643
PG
127if [ "$Q" ]; then
128 mkfontdir 1>/dev/null 2>/dev/null;
129else
130 mkfontdir
131fi;
cd7534e8 132rm -rf "$TMPDIR"
0ea83643
PG
133
134if [ "$DISPLAY" ]; then $Q echo "adjusting X font database"; xset fp rehash; fi;