VFonts.mesa; Last Edited by McGregor, September 1, 1982 2:37 pm
Last Edited by: Maxwell, January 3, 1983 12:12 pm
DIRECTORY
Graphics USING [FontRef],
Rope USING [ROPE];
VFonts: CEDAR DEFINITIONS = BEGIN
This package is intended as a temporary solution to the problem of different font formats in the Graphics, Viewers, and Tioga worlds. Clients of Viewers should always use this package to create new fonts and then use the GraphicsFont interface to acquire a Graphics.FontRef if they need one.
Font: TYPE = REF FontObject;
defaultFont: Font;
defaultGFont: Graphics.FontRef;
GraphicsFont: PROC [vFont: Font] RETURNS [Graphics.FontRef] = INLINE
{RETURN[vFont.gFont]} ;
Returns a Graphics style font given a VFont.Font
EstablishFont: PUBLIC PROC [family: Rope.ROPE, size: CARDINAL, bold: BOOLFALSE,
italic: BOOLFALSE, defaultOnFailure: BOOLTRUE] RETURNS [Font] ;
Build a (possibly) new font. The default font will be returned on any error condition unless defaultOnFailure is FALSE.
CharWidth: PROC [char: CHAR, font: Font ← defaultFont]
RETURNS [[0..LAST[INTEGER]]] = INLINE {RETURN[font.width[char]]};
StringWidth: PROC [string: Rope.ROPE, font: Font ← defaultFont]
RETURNS [[0..LAST[INTEGER]]] ;
FontHeight: PROC [font: Font ← defaultFont] RETURNS [[0..LAST[INTEGER]]] =
INLINE {RETURN [font.height]} ;
FontAscent: PROC [font: Font ← defaultFont] RETURNS [[0..LAST[INTEGER]]] =
INLINE {RETURN [font.ascent]} ;
XInSegment: PROC [char: CHAR, font: Font] RETURNS [CARDINAL] =
TRUSTED INLINE {RETURN[font.xInSegment[char]]} ;
Bitblt x offset in font bitmap
Error: ERROR [code: ErrorCode] ;
ErrorCode: TYPE = {illegalFormat, fontNotFound} ;
FontObject: TYPE = PRIVATE RECORD [
height: CARDINALNULL,
ascent: CARDINALNULL,
kerned: BOOLNULL,
width: PACKED ARRAY CHAR[0C..177C] OF [0..256) ← NULL,
raster: CARDINALNULL,
maxWidth: CARDINALNULL,
min, max: CHARNULL,
address: LONG POINTERNIL,
bitmap: LONG POINTER TO ARRAY [0..0) OF WORDNULL,
xInSegment: LONG POINTER TO ARRAY CHAR[0C..0C) OF CARDINALNULL,
family: Rope.ROPENIL,
size: CARDINALNULL, -- in points
gFont: Graphics.FontRef ← NIL,
bold: BOOLFALSE,
italic: BOOLFALSE,
synthBold: BOOLFALSE,
synthItalic: BOOLFALSE,
next: Font ← NIL
];
END.