#!/bin/ksh -p 
#
# ident "@(#)utaddfontpath.ksh	1.2	09/12/17 SMI"
#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

#
# This command is intended to be called by loginGUI. This
# command takes one argument locale
#

set -u
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/X11R6/bin:/usr/openwin/bin
MOD="`basename $0`"

OPENWINHOME=/usr/openwin

if ! whence xset > /dev/null 2>&1 ; then
        logger -p user.warning -t "$MOD" "Cannot find xset tool"
	exit 1	
fi

usage() {
        print -u2 "
Usage: $MOD <locale>
"
        exit 1
}

#
# Handle locale fonts
#
ADDFONTPATH() {
        # Combine lines together to make arguments for the xset command
        FP=`awk '
        BEGIN { fp="fp+ " }
        /^[     ]*$/ { fp=" +fp " ; continue }
        { printf("%s%s", fp, $0) ; fp="," } ' $1`
        if [ -n "$FP" ]; then
                eval "xset $FP"
        fi
        xset fp rehash
}

#
# Start main code here
#

LOCALE=${1}
if [[ -n "${LOCALE:-}" &&
                -r $OPENWINHOME/lib/locale/$LOCALE/OWfontpath ]]; then
                        ADDFONTPATH $OPENWINHOME/lib/locale/$LOCALE/OWfontpath
fi
