5 # Requires: /bin/sh textutils fileutils
7 # mkfontdir, mkfontscale (XFree86) (or ttmkfdir - for TTF only)
8 # fc-cache (fontconfig or XFree86-fontconfig)
9 # gnome-font-install (gnome-print)
12 FBASEDIR="/usr/share/fonts"
14 MKFONTDIRBIN="/usr/X11R6/bin/mkfontdir"
15 MKFONTDIR="$MKFONTDIRBIN"
16 MKFONTSCALEBIN="/usr/X11R6/bin/mkfontscale"
17 MKFONTSCALE="$MKFONTSCALEBIN"
19 MKTTFFONTSCALEBIN="$MKFONTSCALEBIN"
20 MKTTFFONTSCALE="$MKTTFFONTSCALEBIN"
21 if [ ! -x "$MKFONTSCALEBIN" -a -x /usr/bin/ttmkfdir ]; then
22 # fallback for X <= 4.2.x
23 MKTTFFONTSCALEBIN="/usr/bin/ttmkfdir"
24 MKTTFFONTSCALE="$MKFONTSCALEBIN -e /usr/share/fonts/encodings/encodings.dir"
27 FCCACHEBIN="/usr/bin/fc-cache"
28 if [ ! -x $FCCACHEBIN -a -x /usr/X11R6/bin/fc-cache ]; then
29 # use XFree86-fontconfig
30 FCCACHEBIN="/usr/X11R6/bin/fc-cache"
32 if [ ! -x $FCCACHEBIN -a -x /usr/X11R6/bin/xftcache ]; then
33 # fallback for XFree86 4.[0-2]
34 FCCACHEBIN="/usr/X11R6/bin/xftcache"
36 FCCACHE="$FCCACHEBIN ."
38 GNOMEFONTINSTBIN="/usr/bin/gnome-font-install"
39 if [ ! -x $GNOMEFONTINSTBIN -a -x /usr/X11R6/bin/gnome-font-install ]; then
41 GNOMEFONTINSTBIN="/usr/X11R6/bin/gnome-font-install"
43 GNOMEFONTINST="$GNOMEFONTINSTBIN --target $FBASEDIR/fontmap"
45 T1LIBCONFIGBIN="/usr/bin/t1libconfig"
46 T1LIBCONFIG="$T1LIBCONFIGBIN --force"
49 echo "Usage: fontpostinst TYPE [DIR]"
50 echo " TYPE is one of:"
51 echo " OTF, TTF, Type1, misc, 100dpi, 75dpi, cyrillic, local, CID, Speedo, PEX"
52 echo " default DIR is $FBASEDIR/TYPE"
58 FDIR="$FBASEDIR/$FTYPE"
65 if [ "`echo fonts.alias.*`" != 'fonts.alias.*' ]; then
66 cat fonts.alias.* | LC_ALL=C sort -u > fonts.alias
67 elif [ -f fonts.alias ]; then
68 mv -f fonts.alias fonts.alias-save
72 if [ -x $MKTTFFONTSCALEBIN ]; then
75 if [ -x $MKFONTDIRBIN ]; then
78 if [ -x $FCCACHEBIN ]; then
83 rm -f fonts.scale.bak Fontmap.bak
84 if [ "`echo fonts.scale.*`" != 'fonts.scale.*' ]; then
85 cat fonts.scale.* 2>/dev/null | LC_ALL=C sort -u > fonts.scale.tmp
86 cat fonts.scale.tmp | wc -l | tr -d ' ' > fonts.scale
87 cat fonts.scale.tmp >> fonts.scale
89 elif [ "`echo *.pf[ab]`" != '*.pf[ab]' ]; then
90 # no hints - try to generate
91 if [ -x $MKFONTSCALEBIN ]; then
94 elif [ -f fonts.scale ]; then
95 mv -f fonts.scale fonts.scale-save
97 if [ -x $MKFONTDIRBIN ]; then
100 if [ -x $FCCACHEBIN ]; then
103 if [ "`echo Fontmap.*`" != 'Fontmap.*' ]; then
104 cat Fontmap.* > Fontmap
105 elif [ -f Fontmap ]; then
106 mv -f Fontmap Fontmap-save
108 if [ -x $GNOMEFONTINSTBIN ]; then
111 if [ -x $T1LIBCONFIGBIN ]; then
116 if [ "`echo fonts.scale.*`" != 'fonts.scale.*' ]; then
117 cat fonts.scale.* 2>/dev/null | LC_ALL=C sort -u > fonts.scale.tmp
118 cat fonts.scale.tmp | wc -l | tr -d ' ' > fonts.scale
119 cat fonts.scale.tmp >> fonts.scale
120 rm -f fonts.scale.tmp
121 elif [ -f fonts.scale ]; then
122 mv -f fonts.scale fonts.scale-save
124 if [ -x $MKFONTDIRBIN ]; then
129 # special case - fonts needed for X server to start
130 if [ -x $MKFONTDIRBIN ]; then
132 elif [ -f 6x13-ISO8859-1.pcf.gz -a -f cursor.pcf.gz ]; then
133 cat > fonts.dir <<EOF
135 6x13-ISO8859-1.pcf.gz -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
139 if [ -x $FCCACHEBIN ]; then
143 100dpi|75dpi|cyrillic|local)
144 if [ -x $MKFONTDIRBIN ]; then
147 if [ -x $FCCACHEBIN ]; then
154 echo "Warning: \"$FTYPE\": unknown font type!" >&2
155 if [ -x $MKFONTDIRBIN ]; then