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