ImagerFontCache.mesa
Michael Plass, September 26, 1983 10:12 am
This interface provides a mechanism for caching device- or resolution-dependent representations (of characters, for example) that are derived from some device-independent representation. The cached representations are automatically flushed when the font package deems it appropriate to do so, based on how much they have been used recently, how expensive they are to create, and how much storage they use.
ImagerFontCache: CEDAR DEFINITIONS ~ BEGIN
FontCache: TYPE ~ REF FontCacheRep;
FontCacheRep: TYPE;
FontCode: TYPE ~ CARDINAL;
FontObject: TYPE ~ REF FontObjectRep;
FontObjectRep: TYPE ~ MACHINE DEPENDENT RECORD [
Machine dependent to make sure there are no unused bits in the record, so hashing will work.
CharDataProc: PROC [self: FontObject, charCode: CARDINAL]
RETURNS [charData: REF, memoryCost: INT],
charCode is a character code (but not resticted to 8 bits by this package)
charData is the device-dependent character representation desired by the client
memoryCost is a hint to the font cache manager
r0, r1, r2, r3, r4, r5: REAL,
may be used to represent a transformation
fontScalarData: INT,
For client use
fontAnyData: REF
For client use; should be canonicalized for best results.
];
Create: PROC RETURNS [FontCache];
Makes a new font cache.
GetFontCode: PROC [fontObjectRep: FontObjectRep] RETURNS [fontCode: FontCode];
GetCharData: PROC [fontCache: FontCache, fontCode: FontCode, charCode: CARDINAL]
RETURNS [charData: REF];
For getting the cached REF data associated with a given character in a given font.
GetStringData: PROC [action: PROC [charCode: CARDINAL, charData: REF], fontCache: FontCache, fontCode: FontCode, ropeOrRefText: REF, start: INT ← 0, length: INTLAST[INT]];
For getting the cached REFs associated with each character in a string.
Warning: the action proc is called inside of a monitor.
GetNSStringData: PROC [action: PROC [charCode: CARDINAL, charData: REF], fontCache: FontCache, fontCode: FontCode, ropeOrRefText: REF];
Like GetStringData, but the string is encoded using the Interpress string-body encoding, i.e., a character of '\377 is treated as an escape code that precedes a byte containing the high-order 8 bits of a new character code offset.
InterpretFontCode: PROC [fontCode: FontCode] RETURNS [FontObject];
May raise:
InvalidFontCode: ERROR;
EnumerateFontCodes: PROC [action: PROC [fontCode: FontCode, fontObject: FontObject] RETURNS [flush: BOOLEANFALSE]];
Enumerates all valid font codes, making invalid any for which the action proc returns TRUE.
Warning: the action proc is called inside of a monitor.
END.