There are about 100 fzx fonts you can look at in the library:
https://github.com/z88dk/z88dk/tree/mas ... /fzx/fonts
The fzx routines are in classic but it looks like the header file was not included. That can be fixed fairly quickly.
This is the header file:
https://github.com/z88dk/z88dk/blob/mas ... /fzx.h#L35
Create a static fzx_state structure to hold the printing state.
Initialize it with a call to fzx_init()
https://github.com/z88dk/z88dk/blob/mas ... /fzx.h#L90
You're providing the font and the window in this call. The window is the "paper" area where text is rendered into and is measured in 16-bit pixel units. A struct rect_16 holds members x, width, y, height. This will also initialize the other members mainly to 0 but left margin to 3 (iirc to allow kerning) and sets the draw function to xor.
You may want to statically initialize the fzx_state structure instead of calling fzx_init. In particular with a fixed width font you may not want to have a left margin as you won't have any kerning. For filling in the structure, the provided draw functions are or, xor, clear ( https://github.com/z88dk/z88dk/blob/mas ... /fzx.h#L76
). On the spectrum the colour members fgnd_attr and fgnd_mask determine output colour. It's an AND/OR operation.. first the existing colour on screen is ANDed with fgnd_mask and that is ORed with fgnd_attr to form the final colour. Set fgnd_attr=0 and fgnd_mask=0xff to keep the existing colour on screen; there is special code that detects this to skip the colouring.
As you can see the fzx_state structure contains the current x and y coordinate in pixels. These coords are relative to the "paper" defined as the window. You can change features like font, coords, etc, by directly changing members at any time.
To include your own font just import it via an asm file like this:
And then add this asm file to your compile.
In your C program, add this to the header so that the C compiler can find the start address of the font:
extern struct fzx_font myfont;
The lowest level output is fzx_putc that puts out one char ( https://github.com/z88dk/z88dk/blob/mas ... fzx.h#L101
). It's useful to look at the implementation to find out what is indicated in the return value - https://github.com/z88dk/z88dk/blob/mas ... tc.asm#L31
. You actually have to look at the c interface code for this one but what it does is return A (0 or 1) on error or a screen address on success. This function will adjust the x coord on success but it only returns an error if the char does not fit horizontally or vertically.
fzx_puts() will print a zero-terminated string and will move to the next line automatically. fzx_write() is similar but does a buffer with length. These generic routines are in https://github.com/z88dk/z88dk/tree/mas ... nt/fzx/z80
. There are also routines for word wrapping, measuring pixel width of strings and printing justified text.
If you also need to do typed input, you may want to use the stdio driver for both output and input.
For a very small font, your original approach might not be too bad if it is re-written to be quicker.
Anyway, as the fzx header is missing in classic at the moment, you can just copy the appropriate header out of the newlib and include it locally with #include "fzx.h".
sccz80: https://github.com/z88dk/z88dk/blob/mas ... font/fzx.h
zsdcc: https://github.com/z88dk/z88dk/blob/mas ... fzx.h#L101