[comp.os.minix] Change font for Minix-ST

dal@syntel.UUCP (Dale Schumacher) (05/19/89)

Are you as sick as I am of the Atari system font?  Well, here is a way
to change all that.  I never have been able to put up with that ugly
font, so I made a small change to the 'kernel/stfnt.c' file to allow
you to define font data externally, alas, only a compile time for now.
I hope to later make font loading an ioctl(), but that's much more
complicated than this solution.

Also included here is an implementation of the classic 'dump' program.
It displays offset on the left, hex data in the middle, and ascii on
the right.  I've included it here because I've added a somewhat unusual
option to allow creation of C array initializers from binary data,
which is how the font files are stored (2K versus 17K EACH).

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	readme
#	stfnt.cdf
#	dump.c
#	clean_16.uue
#	courier.uue
# This archive created: 19-May-1989 2:38:00 ENOENV
# By:	ENOENV (ENOENV)
cat << \SHAR_EOF > readme
These files will help you change the console font used by Minix-ST.

DUMP.C		source for a hex-dump program with the classic
		hex on the left, ascii on the right format, plus
		the option to output C array initializers.

STFNT.CDF	context diff for the 'kernel/stfnt.c' file to
		allow inclusion of the external font data.

CLEAN_16.UUE	binary font files which may be 'dump'ed to create
COURIER.UUE	initializers for the system font16 array.

The 'kernel/stfnt.c' file simply contains static initialized arrays
which hold the font bitmaps.  The format is very simple, the same
as the data portion of a Degas(tm) font file.  To replace the font,
all you need to do is create (using the 'dump' provided) a new font
data array from one of the two fonts provided and put it in the the
file '/etc/fonts/font16.c'.  The fonts are both 16 scanlines high
(as are all Degas font files), so if you want a font for color
(8 scanlines), you'll have to get a different font definition, but
the hooks for including either or both fonts are already there.
You will then need to recompile 'stfnt.c' with -DNEWFONT16 and/or
-DNEWFONT8 depending on which font(s) you want to replace.  The
fonts themselves are freely available, since I designed both of
them myself from scratch.  The "courier" is, of course, based on
a "Courier 12" font example in a lettering guide.  I have many other
fonts as well, if someone is interested in more variations, but many
of them do not use a full 16-scanline high cell.  Enjoy.

			Dale Schumacher <dal@syntel.UUCP>

PS.  I really dislike the default system font :-P
SHAR_EOF
cat << \SHAR_EOF > stfnt.cdf
*** v1.1/kernel/stfnt.c	Thu May  6 19:17:01 1989
--- working/kernel/stfnt.c	Thu May 19 00:00:12 1989
***************
*** 18,24 ****
   */
  #include "../h/const.h"
  
! PUBLIC char font16[] = {
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x18,0x3C,0x66,0xC3,0x81,0xE7,0x24,0x24,0x24,0x3C,0x00,0x00,0x00,
  0x00,0x00,0x00,0x3C,0x24,0x24,0x24,0xE7,0x81,0xC3,0x66,0x3C,0x18,0x00,0x00,0x00,
--- 18,28 ----
   */
  #include "../h/const.h"
  
! PUBLIC char font16[] =
! #ifdef NEWFONT16
! #include "/etc/fonts/font16.c"
! #else
! {
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x18,0x3C,0x66,0xC3,0x81,0xE7,0x24,0x24,0x24,0x3C,0x00,0x00,0x00,
  0x00,0x00,0x00,0x3C,0x24,0x24,0x24,0xE7,0x81,0xC3,0x66,0x3C,0x18,0x00,0x00,0x00,
***************
*** 148,155 ****
  0x00,0x00,0x00,0x00,0x00,0x62,0xF2,0xBE,0x9C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x3C,0x24,0x66,0x42,0xC3,0xFF,0x00,0x00,0x00,
  };
! 
! PUBLIC char font8[] = {
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x18,0x3C,0x66,0xC3,0xE7,0x24,0x24,0x3C,
  0x3C,0x24,0x24,0xE7,0xC3,0x66,0x3C,0x18,
--- 152,164 ----
  0x00,0x00,0x00,0x00,0x00,0x62,0xF2,0xBE,0x9C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x3C,0x24,0x66,0x42,0xC3,0xFF,0x00,0x00,0x00,
  };
! #endif /* NEWFONT16 */
! 
! #ifdef NEWFONT8
! #include "/etc/fonts/font8.c"
! #else
! PUBLIC char font8[] =
! {
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x18,0x3C,0x66,0xC3,0xE7,0x24,0x24,0x3C,
  0x3C,0x24,0x24,0xE7,0xC3,0x66,0x3C,0x18,
***************
*** 279,282 ****
  0x00,0x60,0xF2,0x9E,0x0C,0x00,0x00,0x00,
  0x00,0x18,0x18,0x34,0x34,0x62,0x7E,0x00,
  };
! #endif ATARI_ST
--- 288,292 ----
  0x00,0x60,0xF2,0x9E,0x0C,0x00,0x00,0x00,
  0x00,0x18,0x18,0x34,0x34,0x62,0x7E,0x00,
  };
! #endif /* NEWFONT8 */
! #endif ATARI_ST
SHAR_EOF
cat << \SHAR_EOF > dump.c
/*
 *	dump	-- hex dump utility
 *
 *	author:  Dale Schumacher <dal@syntel.UUCP>
 */

#include <stdio.h>
#include <ctype.h>

#define	DEBUG(x)	/* x */

#undef isascii
#define	isascii(x)	(!((x) & ~0x7F))

#ifndef	SEEK_SET
#define	SEEK_SET	0
#define	SEEK_CUR	1
#define	SEEK_END	2
#endif

int	cmode = 0;	/* output a C array initializer */

usage()
	{
	fprintf(stderr, "usage: dump [-c] [{+|-}offset] [file...]\n");
	exit(1);
	}

main(argc, argv)
	int argc;
	char *argv[];
	{
	FILE *f;
	long offset = 0L;

	if((argc > 1) && (argv[1][0] == '-') && (argv[1][1] == 'c'))
		{
		--argc;
		++argv;
		cmode = 1;
		}
	if(argc > 1)
		{
		switch(argv[1][0])
			{
			case '+':
				--argc;
				sscanf(((*++argv) + 1), "%ld", &offset);
				break;
			case '-':
				if((argv[1][1])
				&& (--argc, (*((*++argv) + 1) != '-')))
					{
					sscanf(((*argv) + 1), "%ld", &offset);
					offset = -offset;
					}
				break;
			default:
				break;
			}
		}
	DEBUG(printf("[main: argc=%d offset=%ld]\n", argc, offset));
	if(argc < 2)
		if(isatty(fileno(stdin)))
			usage();
		else
			dump(stdin, offset);
	else
		while(--argc)
			{
			if((**++argv == '-') && (*(*argv + 1) == '\0'))
				{
				dump(stdin, offset);
				}
			else if(f = fopen(*argv, "r"))
				{
				DEBUG(printf("[main: dumping '%s']\n", *argv));
				dump(f, offset);
				fclose(f);
				}
			else
				{
				fputs("dump: ", stderr);
				perror(*argv);
				exit(1);
				}
			}
	exit(0);
	}

dump(f, n)
	FILE *f;
	long n;
	{
	char buf[16];
	int size, primed = 0;

	DEBUG(printf("[dump: offset=%ld]\n", n));
	if(n)
		{
		fseek(f, n, ((n > 0) ? SEEK_SET : SEEK_END));
		n = ftell(f);
		DEBUG(printf("[dump: new offset=%ld]\n", n));
		}
	if(cmode)
		printf("{\n");
	while((size = fread(buf, 1, sizeof(buf), f)) > 0)
		{
		if(cmode)
			{
			if(primed)
				printf(",\n");
			else
				primed = 1;
			}
		show_block(n, buf, size);
		n += ((long) size);
		}
	if(cmode)
		printf("\n};\n");
	}

show_block(offset, p, size)
	long offset;
	char *p;
	register int size;
	{
	register int i;
	register char *q;

	printf((cmode ? "/* %08lx */  " : "%08lx:  "), offset);
	i = 0;
	q = p;
	while(i < 16)
		{
		if(i++ < size)
			printf((cmode ? "0x%02x%s" : "%02x "),
				(0xFF & (*q)),
				((i < size) ?
					((i == 8) ?
						",\n\t\t" :
						", ") :
					""));
		else
			printf("   ");
		++q;
		}
	if(!cmode)
		{
		printf(" |");
		for(i=0, q=p; (i < 16); ++i, ++q)
			putchar((i < size) ?
				((isascii(*q) && isprint(*q)) ?
					*q :
					'.') :
				' ');
		printf("|\n");
		}
	}
SHAR_EOF
cat << \SHAR_EOF > clean_16.uue
table
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
begin 644 clean_16.fnt
M                          @4(G<4%!04'          <%!04%'<B% @ z
M          @,>D%Z# @            (&"]!+Q@(          "E9N<8&.=Fy
MI0          ^(B(B/D% P\          .?#I1@8I</G        ?P]G5V!3x
M9 )Q=G!_     '\'5U=P5U(">GIX?P    !_'U]?4$=T!G1U<7\     ?P=7w
M5U G(@IZ>GA_     '\'=T=@1U06='5Q?P    !_!S='0$8U!G5U<'\     v
M!04%!04%#0T-&7EQ     *"@H*"@H+"PL)B>C@      /&9F &9F/       u
M      8&!@ &!@8            \!@8\8& \            / 8&/ 8&/   t
M         &9F9CP&!@8            \8& \!@8\            /&!@/&9Fs
M/            #P&!@ &!@8            \9F8\9F8\            /&9Fr
M/ 8&/                #X# W]C8SX      '\'=T=P0W0$='-X?P      q
M        !P\?&!@0'A<          /#X[ 0$!#Q4$0L-!@<N.3@         p
M  0HV"C0$.                                     (" @(" @(  @(o
M         !04%                "0D)'XD)"1^)"0D      @<*B@H& P*n
M"BH<"        "!04B0($B4% @         \0$ @,$E&1CD         # @0m
M               &# P8&!@8&!@,# 8     ,!@8# P,# P,&!@P        l
M  @(:QP(%"(            (" A_" @(                    &!@0(   k
M         '\                        8&        @($! @($! @($! j
M       \9F9F9F9F9F8\        #!P,# P,# P,#        #QF!@8,&#!@i
M8'X        \9@8&' 8&!F8\        # P<'"PL?@P,'@       'Y@8&!\h
M!@8&9CP        <,&!@?&9F9F8\        ?F8&!@P,&!@P,        #QFg
M9F8\9F9F9CP        \9F9F9CX&!@PX            &!@    8&       f
M     !@8    &!@0(          ''' <!P               '\  '\     e
M         ' <!QQP           ^(0$!!@@(  @(         !PB25552B >d
M           8&#PT-'YB8N,         ?F-C8WYC8V-^         !XS8&!@c
M8& S'@        !\9F-C8V-C9GP         ?V!@8'Q@8&!_         ']@b
M8&!\8&!@8          >,V!@8&=C,Q\         8V-C8W]C8V-C        a
M 'X8&!@8&!@8?@         >!@8&!@9F9CP         8V9L>'!X;&9C    z
M     &!@8&!@8&!@?@        !C8W=W:VMC8V,         8V-S<VMG9V-Cy
M         !PV8V-C8V,V'         !^8V-C?F!@8&          '#9C8V-Cx
M8S8<+08      'YC8V-^;&9C8P         ^8V!@/@,#8SX         ?A@8w
M&!@8&!@8         &-C8V-C8V-C/@        !C8V-C-C8V'!P         v
M8V-C:VMW=V-C         &9F9CP8/&9F9@        !F9F8\&!@8&!@     u
M    ?@8&#!@P8&!^       >&!@8&!@8&!@8&!X     0$ @(! 0" @$! ("t
M     #P,# P,# P,# P,/       &"1"                            s
M    ?P      & @$                    /V-C8V-G.P       &!@8'YCr
M8V-C8WX            ^8&!@8& ^         P,#/V-C8V-C/P          q
M #YC8W]@8#X        /&!@^&!@8&!@8$           /V-C8V-C/P,#/@  p
M &!@8'YC8V-C8V,        8& !X&!@8&!A^        !@8 '@8&!@8&!@8&o
M/    &!@8&-F;'AL9F,        X&!@8&!@8&!@\            =FMK:VMKn
M:P           &YS8V-C8V,            ^8V-C8V,^            ?F-Cm
M8V-C?F!@8        #]C8V-C8S\# P,       !N<&!@8&!@            l
M/F!@/ 8&?        !@8&'X8&!@8& X           !C8V-C8V<[        k
M    8V-C-C8<'            &-C:VMK:SX           !F9CP8/&9F    j
M        8V-C8V-C/P,#/@       'X&#!@P8'X       8,# P,&!@,# P,i
M!@    @(" @(" @(" @(" @(    ,!@8&!@,#!@8&!@P       Q248     h
7              @(%!0B(D%_       8g
 f
end
SHAR_EOF
cat << \SHAR_EOF > courier.uue
table
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
begin 644 courier.fnt
M                          @4(G<4%!04'          <%!04%'<B% @ z
M          @,>D%Z# @            (&"]!+Q@(          "E9N<8&.=Fy
MI0          ^(B(B/D% P\          .?#I1@8I</G        ?P]G5V!3x
M9 )Q=G!_     '\'5U=P5U(">GIX?P    !_'U]?4$=T!G1U<7\     ?P=7w
M5U G(@IZ>GA_     '\'=T=@1U06='5Q?P    !_!S='0$8U!G5U<'\     v
M!04%!04%#0T-&7EQ     *"@H*"@H+"PL)B>C@      /$)" $)"/       u
M      (" @ " @(            \ @(\0$ \            / ("/ ("/   t
M         $)"0CP" @(            \0$ \ @(\            /$! /$)"s
M/            #P" @ " @(            \0D(\0D(\            /$)"r
M/ ("/                #P" GY"0CP      '\'=T=P0W0$='-X?P      q
M        !P\?&!@0'A<          /#X[ 0$!#Q4$0L-!@<N.3@         p
M  0HV"C0$.                                     (" @(" @(  @(o
M         !04%                "0D)'XD)"1^)"0D      @<*B@H& P*n
M"BH<"        "!04B0($B4% @         \0$ @,$E&1CD         # @0m
M               $" @0$! 0$! (" 0     $ @(! 0$! 0$" @0        l
M  @(:QP(%"(            (" A_" @(                    &!@0(   k
M         '\                        8&        @($! @($! @($! j
M       8)$)"0D)"0B08        "!@H" @(" @("        #Q" @($"! @i
M0GX        \0@($& 0" D(\        #!04)"1$?@0$'@       'Y 0$!\h
M @("0CP        <("! 7&)"0D(\        ?D("! 0("! 0$        #Q"g
M0B08)$)"0CP        \0D)"1CH"! 0X            &!@    8&       f
M     !@8    &!@0(         $&&& 8!@$              '\  '\     e
M        0# , PPP0          ^(0$!!@@(  @(         !PB25552B >d
M           8"!P4%#XB(F,         ?B$A(3XA(2%^         !\A0$! c
M0$ A'@        !\(B$A(2$A(GP         ?R$A)#PD("%_         '\Ab
M(20\)" @>          >(D! 0$]"(AX         =R(B(CXB(B)W        a
M #X(" @(" @(/@         >! 0$! 1$1#@         <R(D*# H)")S    z
M     ' @(" @("(B?@        !C-C8J*B(B(F,         9S(R*BHF)B)Ry
M         !PB04%!04$B'         !^(2$A/B @('@         '")!04%!x
M02(<*08      'XA(2$^)"(B<0         _04! /@$!07X         ?TE)w
M" @(" @<         '<B(B(B(B(B'         !W(B(B%!04" @         v
M8R(B*BHV-B(B         &,B%!0(%!0B8P        !C(A04" @("!P     u
M    ?T$"! @0($%_       <$! 0$! 0$! 0$!P     0$ @(! 0" @$! ("t
M     !P$! 0$! 0$! 0$'       &"1"                            s
M    ?P      & @$                    / ("/D)"/0       & @("PRr
M(2$A,FP            <(D! 0"(<        #@("&B9"0D(F&P          q
M #Q"0GY 0#P        .$! \$! 0$! \            &R9"0D(F&@("'   p
M & @("PR(B(B(G<        ("  X" @(" @^        ! 0 / 0$! 0$! 0$o
M.    & @("<D*#@D(F,        X" @(" @(" @^            =DE)24E)n
M20           &PR(B(B(G<            <(D%!02(<            ;#(Am
M(2$R+" @8        !LF0D)")AH" @\       !N,2 @("!X            l
M/$) / )"/        ! 0$'X0$! 0$ X           !F(B(B(B8;        k
M    =R(B%!0("            &,B*BHJ%!0           !C(A0(%")C    j
M        =R(B%!0("! 08        ']"! @0(7\       0(" @($! (" @(i
M!     @(" @(" @(" @(" @(    $ @(" @$! @(" @0       Q248     h
7              @(%!0B(D%_       (g
 f
end
SHAR_EOF
#	End of shell archive
exit 0

--
      Dale Schumacher                         399 Beacon Ave.
      (alias: Dalnefre')                      St. Paul, MN  55104-3527
      ...bungia!midgard.mn.org!syntel!dal     United States of America
             "I may be competitive, but I'm never ruthless"