Removed MSG_WineStartTicks (does not work for multiple address spaces
[wine.git] / tools / font_convert.sh
blobb90edb8511ab9d6012d8688e302a74a80410c6a4
1 #! /bin/bash
3 # default settings
4 TMPDIR=/tmp/fconv.$$;
5 TFILE=`tempfile`;
7 # Where the fnt2bdf utility resides
8 FC=$HOME""/wine/tools/fnt2bdf;
9 # which OEM_CHARSET to use
10 CHARSET="winsys";
11 TARGET=/usr/X11R6/lib/X11/fonts/misc;
12 BDFTOPCF=/usr/X11R6/bin/bdftopcf;
13 PAT="*.fon";
14 Q="";
15 OLDPWD=`pwd`;
17 usage () {
18 echo "usage: "`basename $0`" [-q] [-c charset] [-t fontdir] [-b bdftopcf] [-f fnt2bdf]"
19 echo " [-p pattern] windir"
20 echo
21 echo "this utility scans a directory and its subdirectories for bitmap-fonts"
22 echo "in Windows format, converts them to PCF-fons and installs them. If X"
23 echo "is running, the X fontpath is re-adjusted."
24 echo
25 echo "options:"
26 echo " -q quit operation."
27 echo " -c charset charset name for OEM_CHARSET fonts, default: $CHARSET"
28 echo " -t fontdir directory to install the converted fonts in. This"
29 echo " directory should be a known fontdirectory to X, default:"
30 echo " $TARGET";
31 echo " -b bdftopcf name of the program to call for bdf to pcf conversion,"
32 echo " default: $BDFTOPCF";
33 echo " -f fnt2bdf name of the program to call for winfont to bdf conversion,"
34 echo " default: $FC"
35 echo " -p pattern Shell-Pattern of the filenames to look for. By default, the"
36 echo " utility will look for the pattern "$PAT" (case insensitive)."
37 echo " windir base directory to search."
38 exit 1;
42 while [ "$1" ]; do
43 case $1 in
44 -c ) shift; if [ "$1" ]; then CHARSET=$1; shift; else usage; fi; ;;
45 -t ) shift; if [ "$1" ]; then TARGET=$1; shift; else usage; fi; ;;
46 -b ) shift; if [ "$1" ]; then BDFTOPCF=$1; shift; else usage; fi; ;;
47 -f ) shift; if [ "$1" ]; then FC=$1; shift; else usage; fi; ;;
48 -p ) shift; if [ "$1" ]; then PAT=$1; shift; else usage; fi; ;;
49 -q ) shift; Q=":"; ;;
50 -* ) usage; ;;
51 * ) if [ "$WIND" ]; then usage; else WIND=$1; shift; fi; ;;
52 esac;
53 done;
55 if [ ! "$WIND" ]; then usage; fi;
56 if [ ! -d "$WIND" ]; then $Q echo "$WIND is not a directory"; exit 1; fi;
57 if [ ! -d "$TARGET" ]; then $Q echo "$TARGET is not a directory"; exit 1; fi;
58 type -p $BDFTOPCF 1>/dev/null || { $Q echo "Can 't execute $BDFTOPCF"; exit 1; }
59 type -p $FC 1>/dev/null || { $Q echo "Can't execute $FC"; exit 1; }
61 $Q echo -n "looking for bitmap fonts... "
62 FONTS=`find "$WIND" -iname $PAT 1>$TFILE 2>/dev/null`;
63 if [ $? -ne 0 ]; then
64 $Q echo "$PAT is a invalid sarch expression"; exit 1;
65 fi;
66 i=0;
67 { while read dummy; do FONTS[$i]="$dummy"; i=$[$i+1]; done; } < $TFILE
68 rm $TFILE;
69 $Q echo "done."
71 if [ -z "$FONTS" ]; then $Q echo "Can't find any fonts in $WIND"; exit 1; fi;
73 mkdir $TMPDIR;
74 cd $TMPDIR;
76 for i in "${FONTS[@]}"; do
77 FNT=`basename "$i"`; FNT=${FNT%.???};
78 $Q echo "converting $i";
79 if [ "$Q" ]; then
80 $FC -c $CHARSET -f $FNT "$i" 2>/dev/null;
81 else
82 $FC -c $CHARSET -f $FNT "$i";
83 fi;
84 done;
86 for i in *.bdf; do
87 if [ "$i" == "*.bdf" ]; then echo "No fonts extracted"; exit 0; fi;
88 bdftopcf -o "${i%.???}.pcf" "$i";
89 $Q echo "installing ${i%.???}.pcf";
90 mv "${i%.???}.pcf" $TARGET 2>/dev/null
91 if [ $? -ne 0 ]; then
92 $Q echo "Can't install fonts to $TARGET. Are your root?"; cd $OLDPWD; rm -rf $TMPDIR; exit 1; fi;
93 rm "$i";
94 done;
96 cd $TARGET;
97 $Q echo "running mkfontdir";
98 if [ "$Q" ]; then
99 mkfontdir 1>/dev/null 2>/dev/null;
100 else
101 mkfontdir
103 rmdir $TMPDIR;
105 if [ "$DISPLAY" ]; then $Q echo "adjusting X font database"; xset fp rehash; fi;