V8/usr/man/man9/font.9

Compare this file to the similar file:
Show the results in this format:

.TH FONT 9.5
.SH NAME
font \- jerq font layouts
.SH SYNOPSIS
.B #include <jerq.h>
.br
.B #include <font.h>
.PP
.B typedef struct Fontchar Fontchar;
.br
.B typedef struct Font Font;
.PP
.B extern Font defont;
.SH DESCRIPTION
A
.I Font
is  a character set, stored as a single
Bitmap
with the characters
placed side-by-side.
It is described by the following data structures.
.IP
.ta +5 +5 +\w'unsigned char bottom;   'u
.nf
typedef struct Fontchar {
	short x;		/* left edge of bits */
	unsigned char top;	/* first non-zero scan-line */
	unsigned char bottom;	/* last non-zero scan-line */
	char left;		/* offset of baseline */
	unsigned char width;	/* width of baseline */
} Fontchar;
typedef struct Font {
	short n;		/* number of chars in font */
	char height;	/* height of bitmap */
	char ascent;	/* top of bitmap to baseline */
	long unused;
	Bitmap *bits;	/* where the characters are */
	Fontchar info[n+1];	/* n+1 character descriptors */
} Font;
.fi
.PP
Characters in
.I bits
abut exactly, so the displayed width of the character
.I c
is
.IR Font.info[c+1].x \- Font.info[c].x .
The first
.I left
columns of pixels in a character overlap the previous character.
The upper left corner of the nonempty columns appears at
.RI ( x, 0)
in the bitmap.
.I Width 
is the distance to move horizontally after drawing a character.
The font bitmap has a fixed
.IR height ;
parameters
.I top
and
.I bottom
may be used to optimize the copying of a character in
some circumstances.
.PP
A character drawn at point
.I p
in an arbitrary
Bitmap
has its upper-leftmost dot, including empty space above it in the
Bitmap,
at
.IR p .
.PP
To copy character
.I c
from font
.I f
to point 
.I p
do
.IP
.nf
Fontchar *i = f\->info + c;
.sp .5
bitblt(f\->bits, Rect(i\->x, i\->top, (i+1)\->x, i\->bottom), Pt(p.x+i\->left, p.y+i\->top), fc);
p.x += i\->width;
.PP
.fi
The above example is correct for XOR and OR mode.
For STORE mode, the bitblt call is different because all the scan lines
must be drawn:
.IP
bitblt(f\->bits, Rect(i\->x, 0, (i+1)\->x, f\->height), Pt(p.x+left, p.y), fc);
.PP
Fonts are stored on disk in binary with byte
order that of the terminal.
First in the file is the first eight bytes (up to
.IR unused )
of the
.I Font
strcture,
then the array of
.I Fontchar
structures,
then the data for the bitmap
.IR Font.bits .
The header for the bitmap must be inferred from
.I Font.height
and
.IR Font.info[Font.n].x .
See
.IR string (9.3)
for a description of how to read and write font files.
.SH SEE ALSO
jf(9.1), string(9.3), infont(9.3)