4 # Generating Fontmap for TTF fonts: http://docs.scribus.net/index.php?lang=en&page=gsfont
8 # Requires: /bin/sh textutils fileutils
10 # mkfontdir, mkfontscale (XFree86) (or ttmkfdir - for TTF only)
11 # fc-cache (fontconfig or XFree86-fontconfig)
12 # gnome-font-install (gnome-print)
15 FBASEDIR="/usr/share/fonts"
17 MKFONTDIRBIN="/usr/bin/mkfontdir"
18 MKFONTDIR="$MKFONTDIRBIN"
19 if [ ! -x "$MKFONTDIRBIN" -a -x /usr/X11R6/bin/mkfontdir ]; then
20 MKFONTDIR="/usr/X11R6/bin/mkfontdir"
22 MKFONTSCALEBIN="/usr/bin/mkfontscale"
23 MKFONTSCALE="$MKFONTSCALEBIN"
24 if [ ! -x "$MKFONTSCALEBIN" -a -x /usr/X11R6/bin/mkfontscale ]; then
25 MKFONTSCALEBIN="/usr/X11R6/bin/mkfontscale"
27 MKTTFFONTSCALEBIN="$MKFONTSCALEBIN"
28 MKTTFFONTSCALE="$MKTTFFONTSCALEBIN"
29 if [ ! -x "$MKFONTSCALEBIN" -a -x /usr/bin/ttmkfdir ]; then
30 # fallback for X <= 4.2.x
31 MKTTFFONTSCALEBIN="/usr/bin/ttmkfdir"
32 MKTTFFONTSCALE="$MKFONTSCALEBIN -e /usr/share/fonts/encodings/encodings.dir"
35 FCCACHEBIN="/usr/bin/fc-cache"
36 if [ ! -x $FCCACHEBIN -a -x /usr/X11R6/bin/fc-cache ]; then
37 # use XFree86-fontconfig
38 FCCACHEBIN="/usr/X11R6/bin/fc-cache"
40 if [ ! -x $FCCACHEBIN -a -x /usr/X11R6/bin/xftcache ]; then
41 # fallback for XFree86 4.[0-2]
42 FCCACHEBIN="/usr/X11R6/bin/xftcache"
44 FCCACHE="$FCCACHEBIN ."
46 GNOMEFONTINSTBIN="/usr/bin/gnome-font-install"
47 if [ ! -x $GNOMEFONTINSTBIN -a -x /usr/X11R6/bin/gnome-font-install ]; then
49 GNOMEFONTINSTBIN="/usr/X11R6/bin/gnome-font-install"
51 GNOMEFONTINST="$GNOMEFONTINSTBIN --target $FBASEDIR/fontmap"
53 T1LIBCONFIGBIN="/usr/bin/t1libconfig"
54 T1LIBCONFIG="$T1LIBCONFIGBIN --force"
57 echo "Usage: fontpostinst TYPE [DIR]"
58 echo " TYPE is one of:"
59 echo " OTF, TTF, Type1, misc, 100dpi, 75dpi, cyrillic, local, CID, Speedo, PEX"
60 echo " default DIR is $FBASEDIR/TYPE"
66 FDIR="$FBASEDIR/$FTYPE"
73 if [ "`echo fonts.alias.*`" != 'fonts.alias.*' ]; then
74 cat fonts.alias.* | LC_ALL=C sort -u > fonts.alias
75 elif [ -f fonts.alias ]; then
76 mv -f fonts.alias fonts.alias-save
80 if [ -x $MKTTFFONTSCALEBIN ]; then
83 if [ -x $MKFONTDIRBIN ]; then
86 if [ -x $FCCACHEBIN ]; then
91 rm -f fonts.scale.bak Fontmap.bak
92 if [ "`echo fonts.scale.*`" != 'fonts.scale.*' ]; then
93 cat fonts.scale.* 2>/dev/null | LC_ALL=C sort -u > fonts.scale.tmp
94 cat fonts.scale.tmp | wc -l | tr -d ' ' > fonts.scale
95 cat fonts.scale.tmp >> fonts.scale
97 elif [ "`echo *.pf[ab]`" != '*.pf[ab]' ]; then
98 # no hints - try to generate
99 if [ -x $MKFONTSCALEBIN ]; then
102 elif [ -f fonts.scale ]; then
103 mv -f fonts.scale fonts.scale-save
105 if [ -x $MKFONTDIRBIN ]; then
108 if [ -x $FCCACHEBIN ]; then
111 if [ "`echo Fontmap.*`" != 'Fontmap.*' ]; then
112 cat Fontmap.* > Fontmap
113 elif [ -f Fontmap ]; then
114 mv -f Fontmap Fontmap-save
116 if [ -x $GNOMEFONTINSTBIN ]; then
119 if [ -x $T1LIBCONFIGBIN ]; then
124 if [ "`echo fonts.scale.*`" != 'fonts.scale.*' ]; then
125 cat fonts.scale.* 2>/dev/null | LC_ALL=C sort -u > fonts.scale.tmp
126 cat fonts.scale.tmp | wc -l | tr -d ' ' > fonts.scale
127 cat fonts.scale.tmp >> fonts.scale
128 rm -f fonts.scale.tmp
129 elif [ -f fonts.scale ]; then
130 mv -f fonts.scale fonts.scale-save
132 if [ -x $MKFONTDIRBIN ]; then
137 # special case - fonts needed for X server to start
138 if [ -x $MKFONTDIRBIN ]; then
140 elif [ -f 6x13-ISO8859-1.pcf.gz -a -f cursor.pcf.gz ]; then
141 cat > fonts.dir <<EOF
143 6x13-ISO8859-1.pcf.gz -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
147 if [ -x $FCCACHEBIN ]; then
151 100dpi|75dpi|cyrillic|local)
152 if [ -x $MKFONTDIRBIN ]; then
155 if [ -x $FCCACHEBIN ]; then
162 echo "Warning: \"$FTYPE\": unknown font type!" >&2
163 if [ -x $MKFONTDIRBIN ]; then