[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#4258: kbd program can't use multiple sized fonts



Package: kbd
Version: 0.91-4

The kbd package config utility has a script called kbdconfig which can be
run to configure keyboard mapping and soft fonts.  These settings are used
on boot by a script /etc/rc.boot/0kbd from a config file /etc/kbd/config.

Some of the fonts have multiple sizes (972.cp for example).  When such a
font is selected, it is necessary to select which size is desired, for
example (setfont /usr/lib/kbd/consolefonts/972.cp -16) would specify size
16.

When such a font is selected by kbdconfig, no mechanism is provided to set
the font size in the boot script, so the font is not loaded.

# setfont /usr/lib/kbd/consolefonts/972.cp
This file contains 3 fonts: 8x8, 8x14 and 8x16. Please indicate
using an option -8 or -14 or -16 which one you want loaded.
#

I am using kernel 2.0.0, Debian 1.1 (unstable tree circa Jun 22 1996), and
libc5.2.18-8 and libc4.6.27-15.

----------------
I have made changes to the /usr/sbin/kbdconfig script to poll the user for
the font size if it is needed (and to save it in the config file), and to
ask the user if they want to enable the configuration when the script
completes.

I have also changed the /etc/rc.boot/0kbd file to use the font size value.

These are the patches ... I'm not familiar enough with diff/patch to give a
full-directory patch of the changes, so I am diff'ing them seperately.


----------> /etc/rc.boot/0kbd

--- 0kbd.old	Tue Jun 25 23:44:33 1996
+++ 0kbd.new	Tue Jun 25 23:44:11 1996
@@ -16,6 +16,7 @@
 	TERM=linux
 	KEYMAP=""
 	SOFTFONT=""
+	SIZE=""
 fi
 
 echo "Console setup:"
@@ -35,5 +36,5 @@
 if [ -n "$SOFTFONT" -a "$SOFTFONT" != "NONE" ]
 then
 	echo -n " "
-	setfont $SOFTFONT
+	setfont $SOFTFONT $SIZE
 fi


---------> /usr/sbin/kbconfig

--- kbdconfig.old	Tue Jun 25 23:45:22 1996
+++ kbdconfig.new	Wed Jun 26 00:00:50 1996
@@ -88,24 +88,101 @@
 	fi
 fi
 
+
+while [ x$fontok != xyes ]
+do
+
 cat << EOT
 
 Please choose one of the following display fonts for the VT devices:
 --------------------------------------------------------------------
 EOT
-(cd $LIBDIR/consolefonts; ls -x)
+	(cd $LIBDIR/consolefonts; ls -x)
+
+	echo -e "\nOr answer NONE to skip the loading of a consolefont."
+	echo -n "What consolefont to load? [$SOFTFONT] "; read softfont
+	if [ -z "$softfont" ]
+	then
+		if [ -n "$SOFTFONT" ]
+		then
+			softfont=$SOFTFONT
+		else
+			softfont=NONE
+		fi
+	fi
+
+# NOTE: We have no way of detecting whether the font makes the screen
+# unreadable or correctly loads;  I know of no way to test if the 
+# font requires a size parameter except to test the program for
+# failure, so we must test for existence of font. -- KMB
 
-echo -e "\nOr answer NONE to skip the loading of a consolefont."
-echo -n "What consolefont to load? [$SOFTFONT] "; read softfont
-if [ -z "$softfont" ]
-then
-	if [ -n "$SOFTFONT" ]
+	bname=$LIBDIR/consolefonts/$softfont
+
+	# Add a default ending if necessary
+
+	[ ! -e $bname -a -e $bname.cp ] && softfont=$softfont.cp
+	[ ! -e $bname -a -e $bname.psf ] && softfont=$softfont.psf
+	
+	if [ ! -e $LIBDIR/consolefonts/$softfont ]
+	then
+		if [ $softfont != NONE ]
+ 		then
+			echo
+			echo Font $softfont not found, setting to NONE.
+			softfont=NONE
+		fi
+	fi
+
+	if [ $softfont != NONE ]
 	then
-		softfont=$SOFTFONT
+		echo ; echo Testing font ... ; echo
+		sleep 2
+		setfont $softfont || SIZE=err
+
+		if [ $SIZE != err ]
+		then
+			sleep 5
+			setfont &> /dev/null
+			echo
+			echo If that font is unacceptable, please
+			echo rerun this script \($0\).
+		fi
 	else
-		softfont=NONE
+		SIZE=NONE
 	fi
-fi
+
+	if [ $SIZE = err ]
+	then
+		echo
+		echo -n "Please enter the font size: "
+		read SIZE
+		if [ $SIZE != NONE ]
+		then
+			echo $SIZE | grep "-" &> /dev/null || SIZE=-$SIZE
+		fi
+
+		echo ; echo Testing font ... ; echo
+		sleep 2
+		setfont $softfont $SIZE || SIZE=err
+
+		if [ $SIZE != err ]
+		then
+			sleep 5
+			setfont &> /dev/null
+			echo
+			echo If that font \(or size\) is unacceptable,
+			echo please rerun this script \($0\).
+		fi
+		
+	fi
+
+	echo
+
+	if [ $SIZE != err ]
+	then
+		fontok=yes
+	fi
+done;
 
 # ##### NOT YET ... #####
 #if [ -n "$advanced_flag"  ]
@@ -117,12 +194,27 @@
 #	echo -n "Should the METABIT flag be set by default [$METABIT]: "; read numlock
 #fi
 
+[ $SIZE = NONE ] && unset SIZE
+
 echo -n  "Generating $CONFFILE... "
 cat > $CONFFILE << EOT
 CONSOLE=$consdev
 TERM=$termtyp
 KEYMAP=$keymap
 SOFTFONT=$softfont
+SIZE=$SIZE
 EOT
 echo "done."
+
+echo
+echo The settings have been saved and will be used automatically
+echo the next time the system boots.  If you want, I can enable 
+echo these settings now.
+echo
+echo -n "Do you want to enable these settings now? [y/N] "
+read immediate
+[ $immediate = y ] || [ $immediate = Y ] || [ $immediate = yes ] \
+	&& echo ; echo Okay, enabling ... ; echo ; /etc/rc.boot/0kbd
+echo
+
 exit 0


-------------------------------

(Obviously change this in any way you want, all rights
UN-reserved ;)

The only thing I don't like about these changes is that kbdconfig runs
setfont to determine if the font needs a size specified.  I don't know if
this could cause problems or not (ie on old vga/ega/cga/mga/hgc whatever),
but:

1) I don't see this as -introducing- a problem, since it only does it if you
specify a font, in which case that font would load on next boot anyway.

2) It does restore a hopefully readable default font after allowing the font
to be viewed, thus guarding against an (is this a possibility?) unviewable
font from being configured and going unnoticed.

In other words, it looks like a feature to me.

__kmb203@psu.edu_________________________Debian/GNU__1.1___Linux__2.0.14___
"The C Programming Language -- a language that combines all the elegance and
power of assembly language with all the readability and maintainability of
assembly language."  (version 2.0 of this signature, thanks Pete :)




Reply to: