e91ffb
#!/bin/sh
e91ffb
# This script is used by the xorg-x11-fonts package in the %post stage for
e91ffb
# some fonts to generate the right encodings.
e91ffb
e91ffb
fontdir=""
e91ffb
encodingsdir="@DATADIR@/X11/fonts/encodings"
e91ffb
e91ffb
# some fonts need to skip mkfontscale, set to "yes" to skip
e91ffb
skip_fontscale=""
e91ffb
# some fonts need to run ttmkfdir, set to "yes" to run
e91ffb
need_ttmkfdir=""
e91ffb
e91ffb
if [ $# -lt 1 ]; then
e91ffb
    echo "Need at least one parameter for font dir."
e91ffb
    exit 1
e91ffb
fi
e91ffb
e91ffb
while [ $# != 0 ]; do
e91ffb
    case $1 in
e91ffb
        --skip-fontscale)
e91ffb
        skip_fontscale="yes"
e91ffb
        ;;
e91ffb
        --need-ttmkfdir)
e91ffb
        need_ttmkfdir="yes"
e91ffb
        ;;
e91ffb
        --encodingsdir)
e91ffb
        shift
e91ffb
        encodingsdir="$1"
e91ffb
        ;;
e91ffb
        *)
e91ffb
        fontdir="$1"
e91ffb
e91ffb
        if [ $# != 1 ]; then
e91ffb
            echo "Too many parameters."
e91ffb
            exit 1
e91ffb
        fi
e91ffb
        ;;
e91ffb
    esac
e91ffb
    shift
e91ffb
done
e91ffb
e91ffb
if [ "$skip_fontscale" != "yes" ]; then
e91ffb
    mkfontscale $fontdir
e91ffb
fi
e91ffb
if [ "$need_ttmkfdir" = "yes" ]; then
e91ffb
    ttmkfdir -d $fontdir -o "$fontdir/fonts.scale"
e91ffb
fi
e91ffb
e91ffb
mkfontdir $fontdir
e91ffb
fc-cache $fontdir
e91ffb
e91ffb
if ! [ -z "$encodingsdir" ]; then
e91ffb
    [ -d "$encodingsdir" ] || mkdir -p "$encodingsdir"
e91ffb
    [ -d "$encodingsdir/large" ] || mkdir -p "$encodingsdir/large"
e91ffb
    oldpwd=$(pwd)
e91ffb
    cd "$encodingsdir"
e91ffb
    mkfontscale -n -e "$encodingsdir" -e "$encodingsdir/large"
e91ffb
    cd ${oldpwd}
e91ffb
fi
e91ffb
e91ffb