#!/bin/sh

EXEC_BASE=/usr
export EXEC_BASE

if [ ! -x $EXEC_BASE/openwin/bin/mkfontdir ]
then
    # if mkfontdir doesn't exist we cannot proceed
    exit 2
fi

FONTINSTDIR=$BASEDIR/openwin/lib/locale/zh.GBK/X11/fonts
export FONTINSTDIR

if [ -d $FONTINSTDIR/TrueType ]; then
      cd $FONTINSTDIR/TrueType

	# Restore fonts.alias.base, fonts.scale.base

       if [ -f fonts.alias.old ]; then
                 rm -f fonts.alias.old
       fi

	if [ -f fonts.alias.base ]; then
		cp -f fonts.alias.base fonts.alias
	fi

	if [ -f fonts.scale.base ]; then
		cp -f fonts.scale.base fonts.scale
	fi

	#  rerun mkfontdir as fonts.scale is changed
       $EXEC_BASE/openwin/bin/mkfontdir .
       FONTEXIST=`head -1 fonts.dir`
       if [ "$FONTEXIST" = '0' ]; then
                rm -f fonts.dir
        fi
fi

FONTINSTDIR=$BASEDIR/openwin/lib/locale/zh_CN.GB18030/X11/fonts
export FONTINSTDIR

if [ -d $FONTINSTDIR/TrueType ]; then
           cd $FONTINSTDIR/TrueType

           # Restore fonts.alias.base, fonts.scale.base

           if [ -f fonts.alias.old ]; then
                        rm -f fonts.alias.old
           fi


	   if [ -f fonts.alias.base ]; then
                cp -f fonts.alias.base fonts.alias
	   fi

	   if [ -f fonts.scale.base ]; then
                cp -f fonts.scale.base fonts.scale
	   fi

            #  rerun mkfontdir as fonts.scale is changed
            $EXEC_BASE/openwin/bin/mkfontdir .
            FONTEXIST=`head -1 fonts.dir`
            if [ "$FONTEXIST" = '0' ]; then
                        rm -f fonts.dir
            fi
fi

exit 0
