ImagerFont.mesa
Copyright © 1984, Xerox Corporation. All rights reserved.
Michael Plass, July 31, 1984 10:58:40 am PDT
Doug Wyatt, November 14, 1984 6:23:24 pm PST
DIRECTORY
ImagerTransformation USING [Transformation],
Prop USING [PropList],
Rope USING [ROPE],
Vector2 USING [VEC];
ImagerFont: CEDAR DEFINITIONS
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
VEC: TYPE ~ Vector2.VEC;
Transformation: TYPE ~ ImagerTransformation.Transformation;
Font: TYPE ~ REF FontRep;
FontRep:
TYPE ~
RECORD[
class: Class,
data: REF,
name: ROPE,
charToClient: Transformation,
props: Prop.PropList
];
Class: TYPE ~ REF ClassRep;
ClassRep:
TYPE ~
RECORD[
Modify: PROC[font: Font, m: Transformation] RETURNS[Font],
Contains: PROC[font: Font, char: Char] RETURNS[BOOL],
NextChar: PROC[font: Font, char: Char] RETURNS[next: Char],
Width: PROC[font: Font, char: Char] RETURNS[VEC],
Amplified: PROC[font: Font, char: Char] RETURNS[BOOL],
Correction: PROC[font: Font, char: Char] RETURNS[CorrectionType],
BoundingBox: PROC[font: Font, char: Char] RETURNS[Extents],
Ligature: PROC[font: Font, char, successor: Char] RETURNS[Char],
NextLigature: PROC[font: Font, char, successor: Char] RETURNS[Char],
Kern: PROC[font: Font, char, successor: Char] RETURNS[VEC],
NextKern: PROC[font: Font, char, successor: Char] RETURNS[Char],
CharInfo: PROC[font: Font, char: Char, key: ATOM] RETURNS[OptionalReal],
MaskChar: PROC[font: Font, char: Char, imager: REF -- Imager.Context --]
];
Char: TYPE ~ CARDINAL;
nullChar: Char ~
CARDINAL.
LAST;
CharSet: TYPE ~ [0..377B];
CorrectionType:
TYPE ~ {none, space, mask};
Extents:
TYPE ~
RECORD[leftExtent, rightExtent, descent, ascent:
REAL];
OptionalReal:
TYPE ~
RECORD[exists:
BOOL, value:
REAL];
Find:
PROC[name:
ROPE]
RETURNS[Font];
Find the font with the given hierarchical name.
It's safe to use RefText.TrustTextAsRope for the name.
Modify:
PROC[font: Font, m: Transformation]
RETURNS[Font];
Modify a font by post-concatenating the given transformation.
Scale:
PROC[font: Font, s:
REAL]
RETURNS[Font];
Equivalent to Modify[font, ImagerTransformation.Scale[s]].
Contains:
PROC[font: Font, char: Char]
RETURNS[
BOOL];
TRUE iff the character exists in the font.
NextChar:
PROC[font: Font, char: Char]
RETURNS[next: Char];
Returns next char in the font, or nullChar.
Call with nullChar to get first char in font.
BoundingBox:
PROC[font: Font, char: Char]
RETURNS[Extents];
Returns a true bounding box for the character mask (not necessarily as tight as possible).
Width:
PROC[font: Font, char: Char]
RETURNS[
VEC];
Amplified:
PROC[font: Font, char: Char]
RETURNS[
BOOL];
Correction:
PROC[font: Font, char: Char]
RETURNS[CorrectionType];
Kern:
PROC[font: Font, char, successor: Char]
RETURNS[
VEC];
Returns kerning adjustment between char and successor, or [0, 0].
NextKern:
PROC[font: Font, char, successor: Char]
RETURNS[Char];
Returns next successor that kerns with char.
Call with successor=nullChar to get first one.
Ligature:
PROC[font: Font, char, successor: Char]
RETURNS[Char];
Returns a ligature formed from char and successor, or nullChar.
NextLigature:
PROC[font: Font, char, successor: Char]
RETURNS[Char];
Returns next successor that has a ligature with char,
Call with successor=nullChar to get first one.
CharInfo:
PROC[font: Font, char: Char, key:
ATOM]
RETURNS[OptionalReal];
Escape hatch for getting other information not included above.
MaskChar:
PROC[font: Font, char: Char, imager:
REF
-- Imager.Context --];
Applies the character mask.
PutProp:
PROC[font: Font, key:
REF, value:
REF];
GetProp:
PROC[font: Font, key:
REF]
RETURNS[value:
REF];
Rope and Text operations treat '\377 as an escape code; see the Xerox Character Code Standard.
MapRope:
PROC[action:
PROC[Char],
rope: ROPE, start: INT ← 0, len: INT ← INT.LAST, set: CharSet ← 0];
MapText:
PROC[action:
PROC[Char],
text: REF READONLY TEXT, start: NAT ← 0, len: NAT ← NAT.LAST, set: CharSet ← 0];
CharWidth:
PROC[font: Font,
char: CHAR, set: CharSet ← 0]
RETURNS[VEC];
RopeWidth:
PROC[font: Font,
rope: ROPE, start: INT ← 0, len: INT ← INT.LAST, set: CharSet ← 0]
RETURNS[VEC];
TextWidth:
PROC[font: Font,
text: REF READONLY TEXT, start: NAT ← 0, len: NAT ← NAT.LAST, set: CharSet ← 0]
RETURNS[VEC];
Rope and Text operations treat '\377 as an escape code; see the Xerox Character Code Standard.
CharBoundingBox:
PROC[font: Font,
char: CHAR, set: CharSet ← 0]
RETURNS[Extents];
RopeBoundingBox:
PROC[font: Font,
rope: ROPE, start: INT ← 0, len: INT ← INT.LAST, set: CharSet ← 0]
RETURNS[Extents];
TextBoundingBox:
PROC[font: Font,
text: REF READONLY TEXT, start: NAT ← 0, len: NAT ← NAT.LAST, set: CharSet ← 0]
RETURNS[Extents];
Register:
PROC[name:
ROPE, file:
ROPE, create:
PROC[
ROPE]
RETURNS[Font]];
Registers a font name; associates a file name and creation procedure with it.
Alias:
PROC[alias:
ROPE, for:
ROPE];
Registers an alias for a font name.
END.