2000-05-30 22:49:07 +02:00
|
|
|
#! /bin/bash
|
2002-03-10 00:29:33 +01:00
|
|
|
#
|
|
|
|
# Copyright 2000 Peter Ganten
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
2000-05-30 22:49:07 +02:00
|
|
|
|
|
|
|
# default settings
|
|
|
|
TMPDIR=/tmp/fconv.$$;
|
|
|
|
TFILE=`tempfile`;
|
|
|
|
|
2002-06-01 04:55:48 +02:00
|
|
|
# Where the fnt2bdf utility resides
|
2000-05-30 22:49:07 +02:00
|
|
|
FC=$HOME""/wine/tools/fnt2bdf;
|
|
|
|
# which OEM_CHARSET to use
|
|
|
|
CHARSET="winsys";
|
|
|
|
TARGET=/usr/X11R6/lib/X11/fonts/misc;
|
|
|
|
BDFTOPCF=/usr/X11R6/bin/bdftopcf;
|
|
|
|
PAT="*.fon";
|
|
|
|
Q="";
|
2002-06-01 04:55:48 +02:00
|
|
|
OLDPWD=`pwd`;
|
2000-05-30 22:49:07 +02:00
|
|
|
|
|
|
|
usage () {
|
|
|
|
echo "usage: "`basename $0`" [-q] [-c charset] [-t fontdir] [-b bdftopcf] [-f fnt2bdf]"
|
|
|
|
echo " [-p pattern] windir"
|
2002-06-01 04:55:48 +02:00
|
|
|
echo
|
2000-05-30 22:49:07 +02:00
|
|
|
echo "this utility scans a directory and its subdirectories for bitmap-fonts"
|
|
|
|
echo "in Windows format, converts them to PCF-fons and installs them. If X"
|
|
|
|
echo "is running, the X fontpath is re-adjusted."
|
2002-06-01 04:55:48 +02:00
|
|
|
echo
|
2000-05-30 22:49:07 +02:00
|
|
|
echo "options:"
|
|
|
|
echo " -q quit operation."
|
|
|
|
echo " -c charset charset name for OEM_CHARSET fonts, default: $CHARSET"
|
|
|
|
echo " -t fontdir directory to install the converted fonts in. This"
|
|
|
|
echo " directory should be a known fontdirectory to X, default:"
|
|
|
|
echo " $TARGET";
|
|
|
|
echo " -b bdftopcf name of the program to call for bdf to pcf conversion,"
|
|
|
|
echo " default: $BDFTOPCF";
|
|
|
|
echo " -f fnt2bdf name of the program to call for winfont to bdf conversion,"
|
|
|
|
echo " default: $FC"
|
|
|
|
echo " -p pattern Shell-Pattern of the filenames to look for. By default, the"
|
|
|
|
echo " utility will look for the pattern "$PAT" (case insensitive)."
|
|
|
|
echo " windir base directory to search."
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while [ "$1" ]; do
|
|
|
|
case $1 in
|
|
|
|
-c ) shift; if [ "$1" ]; then CHARSET=$1; shift; else usage; fi; ;;
|
|
|
|
-t ) shift; if [ "$1" ]; then TARGET=$1; shift; else usage; fi; ;;
|
|
|
|
-b ) shift; if [ "$1" ]; then BDFTOPCF=$1; shift; else usage; fi; ;;
|
|
|
|
-f ) shift; if [ "$1" ]; then FC=$1; shift; else usage; fi; ;;
|
|
|
|
-p ) shift; if [ "$1" ]; then PAT=$1; shift; else usage; fi; ;;
|
|
|
|
-q ) shift; Q=":"; ;;
|
|
|
|
-* ) usage; ;;
|
2002-06-01 04:55:48 +02:00
|
|
|
* ) if [ "$WIND" ]; then usage; else WIND=$1; shift; fi; ;;
|
2000-05-30 22:49:07 +02:00
|
|
|
esac;
|
|
|
|
done;
|
|
|
|
|
|
|
|
if [ ! "$WIND" ]; then usage; fi;
|
|
|
|
if [ ! -d "$WIND" ]; then $Q echo "$WIND is not a directory"; exit 1; fi;
|
|
|
|
if [ ! -d "$TARGET" ]; then $Q echo "$TARGET is not a directory"; exit 1; fi;
|
|
|
|
type -p $BDFTOPCF 1>/dev/null || { $Q echo "Can 't execute $BDFTOPCF"; exit 1; }
|
|
|
|
type -p $FC 1>/dev/null || { $Q echo "Can't execute $FC"; exit 1; }
|
|
|
|
|
|
|
|
$Q echo -n "looking for bitmap fonts... "
|
|
|
|
FONTS=`find "$WIND" -iname $PAT 1>$TFILE 2>/dev/null`;
|
2002-06-01 04:55:48 +02:00
|
|
|
if [ $? -ne 0 ]; then
|
2000-05-30 22:49:07 +02:00
|
|
|
$Q echo "$PAT is a invalid sarch expression"; exit 1;
|
|
|
|
fi;
|
|
|
|
i=0;
|
|
|
|
{ while read dummy; do FONTS[$i]="$dummy"; i=$[$i+1]; done; } < $TFILE
|
|
|
|
rm $TFILE;
|
|
|
|
$Q echo "done."
|
|
|
|
|
2002-06-01 04:55:48 +02:00
|
|
|
if [ -z "$FONTS" ]; then $Q echo "Can't find any fonts in $WIND"; exit 1; fi;
|
2000-05-30 22:49:07 +02:00
|
|
|
|
2001-11-25 01:51:36 +01:00
|
|
|
mkdir "$TMPDIR"
|
|
|
|
cd "$TMPDIR"
|
2000-05-30 22:49:07 +02:00
|
|
|
|
2002-06-01 04:55:48 +02:00
|
|
|
for i in "${FONTS[@]}"; do
|
2000-05-30 22:49:07 +02:00
|
|
|
FNT=`basename "$i"`; FNT=${FNT%.???};
|
|
|
|
$Q echo "converting $i";
|
2002-06-01 04:55:48 +02:00
|
|
|
if [ "$Q" ]; then
|
2000-05-30 22:49:07 +02:00
|
|
|
$FC -c $CHARSET -f $FNT "$i" 2>/dev/null;
|
|
|
|
else
|
|
|
|
$FC -c $CHARSET -f $FNT "$i";
|
|
|
|
fi;
|
|
|
|
done;
|
|
|
|
|
|
|
|
for i in *.bdf; do
|
2002-06-01 04:55:48 +02:00
|
|
|
if [ "$i" == "*.bdf" ]; then echo "No fonts extracted"; exit 0; fi;
|
2000-05-30 22:49:07 +02:00
|
|
|
bdftopcf -o "${i%.???}.pcf" "$i";
|
|
|
|
$Q echo "installing ${i%.???}.pcf";
|
|
|
|
mv "${i%.???}.pcf" $TARGET 2>/dev/null
|
2002-06-01 04:55:48 +02:00
|
|
|
if [ $? -ne 0 ]; then
|
2001-11-25 01:51:36 +01:00
|
|
|
$Q echo "Can't install fonts to $TARGET. Are your root?"; cd "$OLDPWD"; rm -rf "$TMPDIR"; exit 1; fi;
|
2000-05-30 22:49:07 +02:00
|
|
|
rm "$i";
|
|
|
|
done;
|
|
|
|
|
|
|
|
cd $TARGET;
|
2002-06-01 04:55:48 +02:00
|
|
|
$Q echo "running mkfontdir";
|
2000-05-30 22:49:07 +02:00
|
|
|
if [ "$Q" ]; then
|
|
|
|
mkfontdir 1>/dev/null 2>/dev/null;
|
|
|
|
else
|
|
|
|
mkfontdir
|
|
|
|
fi;
|
2001-11-25 01:51:36 +01:00
|
|
|
rmdir "$TMPDIR"
|
2000-05-30 22:49:07 +02:00
|
|
|
|
|
|
|
if [ "$DISPLAY" ]; then $Q echo "adjusting X font database"; xset fp rehash; fi;
|