fonts and symbolic links

Alexander Gottwald alexander.gottwald@s1999.tu-chemnitz.de
Wed Aug 25 20:13:00 GMT 2004


On Wed, 25 Aug 2004, Igor Pechtchanski wrote:

> > I think of adding a wrapper which reads directories and encodings from
> > configfiles (+some builtins) and does the fontdir update for us.
> 
> Yep, that'd be great.  Thanks.

check the attached script.

bye
	ago
-- 
 Alexander.Gottwald@s1999.tu-chemnitz.de 
 http://www.gotti.org           ICQ: 126018723
-------------- next part --------------
#!/bin/sh
#
# Update font information for X11
#
# Creates fonts.scale, fonts.dir and fonts.cache-1
#
PATH="$PATH:/usr/X11R6/bin"
#
# /etc/X11/font-encodings contains one encoding per line
# /etc/X11/font-dirs contains one fontdir per line
ENC_FILE=/etc/X11/font-encodings
DIR_FILE=/etc/X11/font-dirs

#
# Build ENCODINGS parameter. This is ugly. Who can do it better?
#
ENCODINGS=`
(
cat << EOF
microsoft-cp1250
microsoft-cp1251
microsoft-cp1252
microsoft-cp1253
microsoft-cp1254
microsoft-cp1255
microsoft-cp1256
microsoft-cp1257
microsoft-cp1258
EOF
test -r "$ENC_FILE" && sed -e 's/#.*//' "$ENC_FILE" 
) | while read encoding; do
    echo "-a $encoding"
done`

(
cat << EOF
/usr/X11R6/lib/X11/fonts/100dpi
/usr/X11R6/lib/X11/fonts/75dpi
/usr/X11R6/lib/X11/fonts/misc
/usr/X11R6/lib/X11/fonts/CID
/usr/X11R6/lib/X11/fonts/TTF
/usr/X11R6/lib/X11/fonts/Type1
/usr/X11R6/lib/X11/fonts/cyrillic
/usr/X11R6/lib/X11/fonts/local
EOF
test -r "$DIR_FILE" && sed 's/#.*//' "$DIR_FILE" 
) | while read fontdir; do
    if test -d "$fontdir"; then
        need_update=""
        test -e "$fontdir/fonts.dir" || need_update=1
        test -e "$fontdir/fonts.scale" || need_update=1
        test -n "$need_update" || \
            test "$ENC_FILE" -nt "$fontdir/fonts.dir" && need_update=1
        test -n "$need_update" || \
            find "$fontdir" -not '(' \
            -name fonts.scale -o \
            -name fonts.dir -o \
            -name encodings.dir -o \
            -name fonts.cache-1 ')' \
            -a '(' \
            -newer "$fontdir/fonts.dir" -o \
            -newer "$fontdir/fonts.scale" \
            ')' \
            -mindepth 1 -follow | read line && need_update=1 
        if test -n "$need_update"; then 
            echo "updating $fontdir" >&2
            rm -f "$fontdir/fonts.scale"
            rm -f "$fontdir/fonts.dir"
            mkfontscale $ENCODINGS "$fontdir" || rm -f "$fontdir/fonts.scale"
            mkfontscale -b -s -l $ENCODINGS "$fontdir" || rm -f "$fontdir/fonts.dir"
            fc-cache "$fontdir"
        else
            echo "$fontdir is up-todate. skipping" >&2
        fi
    else
        echo "$fontdir is not a directory. skipping" >&2
    fi
done 



More information about the Cygwin-xfree mailing list