-- CGFont.mesa
-- Last edit by Doug Wyatt, November 2, 1982 3:10 pm

DIRECTORY
Rope USING [ROPE],
StrikeFormat USING [WTable, XTable];

CGFont: CEDAR DEFINITIONS = {

WidthArray: TYPE = PACKED ARRAY CHARACTER OF [0..377B];

Ref: TYPE = REF Rep;

Rep: TYPE = RECORD [
kerned: BOOLEAN, -- plain (FALSE) or kerned (TRUE) strike format
height: [0..77777B], -- font height
min,max: CHARACTER, -- range of defined characters
width: REF WidthArray, -- a width for every character code
dx,dy: INTEGER, -- font bounding box dimensions
ox,oy: INTEGER, -- font bounding box offsets
xtable: LONG POINTER TO StrikeFormat.XTable, -- bitmap positions
wtable: LONG POINTER TO StrikeFormat.WTable, -- widths and kerns (if kerned=TRUE)
bitmap: LONG POINTER TO ARRAY [0..0) OF WORD, -- the strike itself
raster: CARDINAL, -- words per raster line in the strike
address: LONG POINTER, -- virtual address of font
fileName: Rope.ROPENIL, -- name of font file, if available
other: REF ANYNIL -- escape hatch
];

defaultFont: READONLY Ref;

Error: ERROR[type: ErrorType];
ErrorType: TYPE = {bug, fileTooLarge, illegalFormat};

FontHeight: PROC[font: Ref ← defaultFont] RETURNS[NAT]
= INLINE { RETURN[font.height] };

CharWidth: PROC[char: CHARACTER, font: Ref ← defaultFont] RETURNS[NAT]
= INLINE { RETURN[font.width[char]] };

StringWidth: UNSAFE PROC[string: LONG STRING, font: Ref ← defaultFont] RETURNS[NAT];

LoadFont: UNSAFE PROC[name: LONG STRING] RETURNS[Ref];

New: UNSAFE PROC[LONG POINTER] RETURNS[Ref];
-- the long pointer must point to a mapped-in ks or strike font

DefaultFont: PROC RETURNS[Ref];

}.