#!/bin/sh
+# TODO:
+# Generating Fontmap for TTF fonts: http://docs.scribus.net/index.php?lang=en&page=gsfont
+
+# $Id$
+
# Requires: /bin/sh textutils fileutils
# optionally:
# mkfontdir, mkfontscale (XFree86) (or ttmkfdir - for TTF only)
-# fc-cache (XFree86-fontconfig)
+# fc-cache (fontconfig or XFree86-fontconfig)
# gnome-font-install (gnome-print)
+# t1libconfig (t1lib)
FBASEDIR="/usr/share/fonts"
MKTTFFONTSCALEBIN="$MKFONTSCALEBIN"
MKTTFFONTSCALE="$MKTTFFONTSCALEBIN"
-if [ ! -x "$MKFONTSCALEBIN" -a -f /usr/bin/ttmkfdir ]; then
+if [ ! -x "$MKFONTSCALEBIN" -a -x /usr/bin/ttmkfdir ]; then
# fallback for X <= 4.2.x
MKTTFFONTSCALEBIN="/usr/bin/ttmkfdir"
MKTTFFONTSCALE="$MKFONTSCALEBIN -e /usr/share/fonts/encodings/encodings.dir"
fi
-FCCACHEBIN="/usr/X11R6/bin/fc-cache"
+FCCACHEBIN="/usr/bin/fc-cache"
+if [ ! -x $FCCACHEBIN -a -x /usr/X11R6/bin/fc-cache ]; then
+ # use XFree86-fontconfig
+ FCCACHEBIN="/usr/X11R6/bin/fc-cache"
+fi
if [ ! -x $FCCACHEBIN -a -x /usr/X11R6/bin/xftcache ]; then
# fallback for XFree86 4.[0-2]
FCCACHEBIN="/usr/X11R6/bin/xftcache"
fi
GNOMEFONTINST="$GNOMEFONTINSTBIN --target $FBASEDIR/fontmap"
+T1LIBCONFIGBIN="/usr/bin/t1libconfig"
+T1LIBCONFIG="$T1LIBCONFIGBIN --force"
+
if [ -z "$1" ]; then
echo "Usage: fontpostinst TYPE [DIR]"
- echo " TYPE is one of OTF, TTF, Type1, misc, 100dpi, 75dpi, CID, Speedo, PEX"
+ echo " TYPE is one of:"
+ echo " OTF, TTF, Type1, misc, 100dpi, 75dpi, cyrillic, local, CID, Speedo, PEX"
echo " default DIR is $FBASEDIR/TYPE"
exit 1
fi
-
+
FTYPE="$1"
if [ -z "$2" ]; then
FDIR="$FBASEDIR/$FTYPE"
fi
umask 022
-cd "$FDIR"
+cd "$FDIR" || exit 0
if [ "`echo fonts.alias.*`" != 'fonts.alias.*' ]; then
cat fonts.alias.* | LC_ALL=C sort -u > fonts.alias
elif [ -f fonts.alias ]; then
fi
if [ -x $FCCACHEBIN ]; then
$FCCACHE
- elif [ -x $XFTCACHEBIN ]; then
- $XFTCACHE
fi
;;
Type1)
rm -f fonts.scale.bak Fontmap.bak
- if "`echo fonts.scale.*`" != 'fonts.scale.*' ]; then
+ if [ "`echo fonts.scale.*`" != 'fonts.scale.*' ]; then
cat fonts.scale.* 2>/dev/null | LC_ALL=C sort -u > fonts.scale.tmp
cat fonts.scale.tmp | wc -l | tr -d ' ' > fonts.scale
cat fonts.scale.tmp >> fonts.scale
rm -f fonts.scale.tmp
- else if [ "`echo *.pf[ab]`" != '*.pf[ab]' ]; then
+ elif [ "`echo *.pf[ab]`" != '*.pf[ab]' ]; then
# no hints - try to generate
if [ -x $MKFONTSCALEBIN ]; then
$MKFONTSCALE
fi
if [ -x $FCCACHEBIN ]; then
$FCCACHE
- elif [ -x $XFTCACHEBIN ]; then
- $XFTCACHE
fi
- if "`echo Fontmap.*`" != 'Fontmap.*' ]; then
+ if [ "`echo Fontmap.*`" != 'Fontmap.*' ]; then
cat Fontmap.* > Fontmap
elif [ -f Fontmap ]; then
mv -f Fontmap Fontmap-save
if [ -x $GNOMEFONTINSTBIN ]; then
$GNOMEFONTINST
fi
+ if [ -x $T1LIBCONFIGBIN ]; then
+ $T1LIBCONFIG
+ fi
;;
CID|Speedo)
- if "`echo fonts.scale.*`" != 'fonts.scale.*' ]; then
+ if [ "`echo fonts.scale.*`" != 'fonts.scale.*' ]; then
cat fonts.scale.* 2>/dev/null | LC_ALL=C sort -u > fonts.scale.tmp
cat fonts.scale.tmp | wc -l | tr -d ' ' > fonts.scale
cat fonts.scale.tmp >> fonts.scale
if [ -x $MKFONTDIRBIN ]; then
$MKFONTDIR
fi
+ ;;
misc)
# special case - fonts needed for X server to start
if [ -x $MKFONTDIRBIN ]; then
cursor.pcf.gz cursor
EOF
fi
+ if [ -x $FCCACHEBIN ]; then
+ $FCCACHE
+ fi
;;
- 100dpi|75dpi|cyrillic)
+ 100dpi|75dpi|cyrillic|local)
if [ -x $MKFONTDIRBIN ]; then
$MKFONTDIR
fi
+ if [ -x $FCCACHEBIN ]; then
+ $FCCACHE
+ fi
;;
PEX)
;;
$MKFONTDIR
fi
esac
+exit 0