#! /bin/sh

# $OpenBSD: mksubfont,v 1.1.1.1 2002/05/28 11:24:04 espie Exp $
# Written by Marc Espie, 2002
# Public domain

PREFIX=/usr/local

unset ENCODING SIZE BLUR OUTLINE

while true; do
	case "$1" in
	-o) 
		OUTLINE=$2;;
	-b)
		BLUR=$2;;
    	-s)
		SIZE=$2;;
	-e)
		ENCODING=$2;;
	*)	break;;
	esac
	shift
	shift
done

if [ $# -ne 1 ]; then
	echo "Error: exactly one font should be specified"
	exit 1
fi

: ${ENCODING:=ISO-8859-1}
: ${SIZE:=18}
: ${BLUR:=2}
: ${OUTLINE:=1.5}
outdir=`basename $1 .ttf`
outdir=`basename $outdir .TTF`

mkdir -p $outdir
subfont --outdir $outdir --blur $BLUR --outline $OUTLINE $ENCODING $SIZE "$1" \
    && \
subfont --outdir $outdir --append --blur $BLUR --outline $OUTLINE \
    ${PREFIX}/libdata/mplayer-osd/osd-encoding $SIZE \
    ${PREFIX}/libdata/mplayer-osd/osd.pfb

echo "You can now move (or link) the contents of $outdir into ~/.mplayer/font"
