ImagerTypeface.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
Doug Wyatt, May 7, 1986 4:40:40 pm PDT
DIRECTORY
Atom USING [PropList],
BasicTime USING [GMT, nullGMT],
FS USING [OpenFile],
Imager USING [Context],
ImagerFont USING [BYTE, CorrectionType, Extents, XChar],
Rope USING [ROPE],
Vector2 USING [VEC];
ImagerTypeface: CEDAR DEFINITIONS
~ BEGIN
VEC: TYPE ~ Vector2.VEC;
ROPE: TYPE ~ Rope.ROPE;
BYTE: TYPE ~ ImagerFont.BYTE;
XChar: TYPE ~ ImagerFont.XChar;
CorrectionType: TYPE ~ ImagerFont.CorrectionType;
Extents: TYPE ~ ImagerFont.Extents;
Typeface: TYPE ~ REF TypefaceRep;
TypefaceRep: TYPE ~ RECORD [
class: TypefaceClass,
data: REF,
name: ROPENIL,
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],
Width: 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: Imager.Context],
Path: PROC [self: Typeface, char: XChar, moveTo: ImagerPath.MoveToProc,
lineTo: ImagerPath.LineToProc, curveTo: ImagerPath.CurveToProc,
conicTo: ImagerPath.ConicToProc, arcTo: ImagerPath.ArcToProc],
propList: Atom.PropList ← NIL
];
InfoTable: TYPE ~ REF InfoTableRep;
InfoTableRep: TYPE ~ PACKED ARRAY BYTE OF Info;
Info: TYPE ~ RECORD [
exists: BOOLFALSE,
amplified: BOOLFALSE,
correction: CorrectionType ← none,
hasKerns: BOOLFALSE,
hasLigatures: BOOLFALSE,
spare1, spare2: BOOLFALSE
];
Find: PROC [name: ROPE] RETURNS [Typeface];
Finds the typeface with the specified name.
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.
END.