DIRECTORY
Atom USING [PropList],
BasicTime USING [GMT, nullGMT],
FS USING [OpenFile],
II USING [Context],
IIFont USING [BYTE, CorrectionType, Extents, Font, XChar],
IITransformation USING [Transformation],
Rope USING [ROPE],
Vector2 USING [VEC];
VEC: TYPE ~ Vector2.VEC;
ROPE: TYPE ~ Rope.ROPE;
BYTE: TYPE ~ IIFont.BYTE;
XChar: TYPE ~ IIFont.XChar;
CorrectionType: TYPE ~ IIFont.CorrectionType;
Extents: TYPE ~ IIFont.Extents;
Font: TYPE ~ IIFont.Font;
Transformation: TYPE ~ IITransformation.Transformation;
Typeface: TYPE ~ REF TypefaceRep;
TypefaceRep:
TYPE ~
RECORD [
class: TypefaceClass,
data: REF,
name: ROPE ← NIL,
created: BasicTime.GMT ← BasicTime.nullGMT,
info: InfoTable ← NIL, -- for character set 0
propList: Atom.PropList ← NIL
];
TypefaceClass: TYPE ~ REF TypefaceClassRep;
TypefaceClassRep:
TYPE ~
RECORD [
type: ATOM,
Contains: PROC [self: Typeface, char: XChar] RETURNS [BOOL],
NextChar: PROC [self: Typeface, char: XChar] RETURNS [next: XChar],
Escapement: PROC [self: Typeface, char: XChar] RETURNS [VEC],
Amplified: PROC [self: Typeface, char: XChar] RETURNS [BOOL],
Correction: PROC [self: Typeface, char: XChar] RETURNS [CorrectionType],
BoundingBox: PROC [self: Typeface, char: XChar] RETURNS [Extents],
FontBoundingBox: PROC [self: Typeface] RETURNS [Extents],
Ligature: PROC [self: Typeface, char, successor: XChar] RETURNS [XChar],
NextLigature: PROC [self: Typeface, char, successor: XChar] RETURNS [XChar],
Kern: PROC [self: Typeface, char, successor: XChar] RETURNS [VEC],
NextKern: PROC [self: Typeface, char, successor: XChar] RETURNS [XChar],
Mask: PROC [self: Typeface, char: XChar, context: II.Context],
propList: Atom.PropList ← NIL
];
InfoTable: TYPE ~ REF InfoTableRep;
InfoTableRep: TYPE ~ PACKED ARRAY BYTE OF Info;
Info:
TYPE ~
RECORD [
exists: BOOL ← FALSE,
amplified: BOOL ← FALSE,
correction: CorrectionType ← none,
hasKerns: BOOL ← FALSE,
hasLigatures: BOOL ← FALSE,
spare1, spare2: BOOL ← FALSE
];
FindTypeface:
PROC [name:
ROPE]
RETURNS [Typeface];
Finds the typeface with the specified universal name.
MakeFont:
PROC [typeface: Typeface, m: Transformation]
RETURNS [Font];
Makes a font from the Typeface and a Transformation
MaskChar:
PROC [font: Font, char: XChar, context: II.Context];
Masks a single character; does not cache
CreateProc:
TYPE ~
PROC [file:
FS.OpenFile]
RETURNS [Typeface];
Register:
PROC [extension:
ROPE, create: CreateProc];
Registers a creation procedure for files with the specified file name extension ("ks", "sd", etc.).
FetchCreator:
PROC [extension:
ROPE]
RETURNS [CreateProc];
GenericCreator: TYPE ~ REF GenericCreatorRep;
GenericCreatorRep:
TYPE ~
RECORD [
data: REF,
proc: GenericCreatorProc,
priority: INTEGER ← 0
];
GenericCreatorProc:
TYPE ~
PROC [self: GenericCreator, name:
ROPE]
RETURNS [Typeface];
RegisterGenericCreator:
PROC [genericCreator: GenericCreator];
Generic creators provide the ability to make typefaces that are a computed function of the name; for example, the name might contain real-valued parameters which determine the shape of the font. The registered genericCreators are called in priority order, each getting a chance to claim the typeface by returning a non-NIL value. In case of a priority clash, the last one registered wins. The normal creation procedure effectively has a priority of 1/2.