#! /bin/sh

# Largefont-mkmovixiso

# Determines the size of the movie file and selects normal or large fonts to
# be included on the CD.

# Usage: just like mkmovixiso, with the same parameters, but the movie file
# must be the last command line parameter. If there are more movie files, the
# last one will be used for determining the width.

# The LARGE and the FONT constants can be edited for your preferences.
# The font you are using must exist in the normal directory (e.g.
# /usr/local/share/emovix/mplayer-fonts/polish/ ), the matching large 
# version in e.g. /usr/local/share/emovix/mplayer-fonts/polish-large/ . 

# If midentify is not on the path, you can also edit the midentify variable.

# If the movie is so many pixels wide, the large font will be used, e.g. "500"
LARGE=500

# default font, e.g. "polish" or "cyrillic"
FONT=polish

# midentify script with full path if necessary
midentify=midentify

# Determine the last parameter - that will be the movie file
eval lastparam=\$$#
movie=`echo $lastparam`

lf="
"

if [ -e "$movie" ]; then
# The file is there
	width=`"$midentify" "$movie" | grep ^ID_VIDEO_WIDTH | sed 's/^.*=//'`
	echo -n "Movie width = $width pixels, using "

	if [ $width -ge $LARGE ]; then
	# At least $LARGE pixels wide => call mkmovixiso with large font
		echo "large font."
		mkmovixiso --subtitleFont=$FONT-large "$@"
	else
	# call mkmovixiso with normal font
		echo "normal font."
		mkmovixiso --subtitleFont=$FONT "$@"
	fi
else
	echo "Couldn't find '$movie'.$lf   The movie file must be the last parameter passed to the script."
fi
