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