#!/bin/sh
#
# see: dh_installdeb(1)

set -e

# font alternatives
ALT_GOTHIC_NAME="otf-japanese-gothic"
ALT_MINCHO_NAME="otf-japanese-mincho"
GOTHIC_FONT_ENTRY="/usr/share/fonts/opentype/ipafont/ipag.otf"
MINCHO_FONT_ENTRY="/usr/share/fonts/opentype/ipafont/ipam.otf"
FONT_PRIORITY=120

add_alternate_gothic_font_entry()
{
        update-alternatives --install \
         /usr/share/fonts/opentype/$ALT_GOTHIC_NAME.otf \
         $ALT_GOTHIC_NAME.otf \
         $GOTHIC_FONT_ENTRY \
         $FONT_PRIORITY
}

add_alternate_mincho_font_entry()
{
        update-alternatives --install \
         /usr/share/fonts/opentype/$ALT_MINCHO_NAME.otf \
         $ALT_MINCHO_NAME.otf \
         $MINCHO_FONT_ENTRY \
         $FONT_PRIORITY
}


# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    configure)
        # remove old otf-japanese-gothic alternatives
        update-alternatives --remove $ALT_GOTHIC_NAME $GOTHIC_FONT_ENTRY
        update-alternatives --remove $ALT_MINCHO_NAME $MINCHO_FONT_ENTRY

	# alternatives
        add_alternate_gothic_font_entry
        add_alternate_mincho_font_entry
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


