ImagerFontCache.mesa
Copyright © 1984 Xerox Corporation. All rights reserved.
Michael Plass, September 26, 1983 10:12 am
Doug Wyatt, July 20, 1984 1:51:10 pm PDT
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.
DIRECTORY
Rope USING [ROPE];
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 ← 0,
For client use
fontAnyData: REFNIL
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.
CharAction: TYPE ~ PROC[charCode: CARDINAL, charData: REF] RETURNS[quit: BOOLFALSE];
GetTextData: PROC [action: CharAction, fontCache: FontCache, fontCode: FontCode,
text: REF READONLY TEXT, start: NAT ← 0, length: NATNAT.LAST];
For getting the cached REFs associated with each character in a REF TEXT.
Warning: the action proc is called inside of a monitor.
GetRopeData: PROC [action: CharAction, fontCache: FontCache, fontCode: FontCode,
rope: Rope.ROPE, start: INT ← 0, length: INTINT.LAST];
For getting the cached REFs associated with each character in a ROPE.
Warning: the action proc is called inside of a monitor.
GetNSStringData: PROC [action: CharAction, 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.