(new c lib) changing font at compile time

New features and project activity between releases
Post Reply
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

(new c lib) changing font at compile time

Post by alvin »

Effective with the July 4 build, the font used by stdout can be defined in the c source via pragma or on the compile line.

The new c lib only supports three official targets as of now (cpm, embedded, zx) and only the zx target is capable of drawing text to screen so this addition only affects the zx target at the moment.

The compile time variable manipulated is CRT_FONT which should be set to the address of the font desired. Setting this variable overrides the default font selected in the crt and completely removes the default font from the output binary.

The zx target has three different stdout drivers selected between by the startup value in the compile line.

* startup = 0, 1 (ram compile) 32, 33 (if2 cartridge)
stdout driver uses standard 8x8 font as defined in the Sinclair ROM. startup = 0,1 uses the default font definition in ROM while 32,33 uses a copy of the Sinclair font which will be included in the output binary.

* startup = 4, 5 (ram compile) 36, 37 (if2 cartridge)
stdout driver uses 4x8 font to achieve 64 columns on screen. stdout uses a default font definition supplied in the library that is attached to the output binary.

* startup = 8, 9 (ram compile) 40, 41 (if2 cartridge)
stdout driver uses fzx proportional fonts. The default is "_ff_ind_Termino" whose definition will be attached to the output binary. There are approximately 100 proportional fonts in the library whose names can be discovered by browsing http://z88dk.cvs.sourceforge.net/viewvc ... fzx/fonts/

From the compile line you can change the default font as follows:

zcc +zx -vn -startup=8 -clib=new -O3 test.c -o test -pragma-redefine:CRT_FONT=_ff_ao_RoundelSans

You can also change the default font via pragma in the C source:

Code: Select all

#pragma define CRT_FONT = _ff_ao_RoundelSans

#include <stdio.h>

void main(void)
{
   printf("Hello World!\n");
}
Of course you should use an appropriate font definition for the stdout driver being used (for startup=0,1 you need an 8x8 font and so on).
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Of course that should be pragma-redirect on the compile line and in the c source:

zcc +zx -vn -startup=8 -clib=new -O3 test.c -o test -pragma-redirect:CRT_FONT=_ff_ao_RoundelSans -create-app

Code: Select all

#pragma redirect CRT_FONT = _ff_ao_RoundelSans

#include <stdio.h>

void main(void)
{
   printf("Hello World!\n");
}
pragma-redirect defines a label rather than a numerical constant.
Post Reply