DIRECTORY BasicTime USING [GMT], PDFileFormat USING [Run], Scaled USING [Value], ImagerTransformation USING [Transformation], Rope USING [ROPE]; ImagerMaskCache: CEDAR DEFINITIONS ~ BEGIN Coefficients: TYPE ~ MACHINE DEPENDENT RECORD [a, b, c, d, e, f: REAL]; passwordValue: CARDINAL ~ 0FCACH; Header: TYPE ~ MACHINE DEPENDENT RECORD [ password: CARDINAL, numberOfEntries: LONG CARDINAL, numberOfWords: LONG CARDINAL, totalUsage: LONG CARDINAL ]; EntryType: TYPE ~ MACHINE DEPENDENT {trailer, unused, fontIDCode, transformationCode, mask}; EntryPrefix: TYPE ~ MACHINE DEPENDENT RECORD [ entryType: EntryType, entryLengthInWords: [0..8192) ]; FontIDCodeEntry: TYPE ~ MACHINE DEPENDENT RECORD [ codeValue: CARDINAL, createdTime: BasicTime.GMT, name: PACKED SEQUENCE chars: CARDINAL OF CHAR ]; TransformationCodeEntry: TYPE ~ MACHINE DEPENDENT RECORD [ codeValue: CARDINAL, coefficients: Coefficients, scanConversionType: ScanConversionType ]; ScanConversionType: TYPE ~ MACHINE DEPENDENT RECORD [ rasterAlignment: {unaligned, aligned} _ unaligned, tuning: {none, quick, slow, hand} _ none, sSpread, fSpread: [0..4) _ 0, spare: BOOLEAN _ FALSE, algorithmCode: CHAR _ '\000 ]; MaskRepresentation: TYPE ~ MACHINE DEPENDENT {raster, runs}; MaskEntry: TYPE ~ MACHINE DEPENDENT RECORD [ fontIDCode: CARDINAL, transformationCode: CARDINAL, charCode: INT, usage: CARDINAL, sWidth, fWidth: Scaled.Value, sMinBB, fMinBB: INTEGER, sSizeBB, fSizeBB: CARDINAL, flag: PACKED ARRAY [0..12) OF BOOLEAN, -- for padding and expansion amplified: BOOLEAN, correctSpace: BOOLEAN, correctMask: BOOLEAN, data: SELECT representation: MaskRepresentation FROM raster => [bits: SEQUENCE COMPUTED CARDINAL -- sSize*Ceiling[fSize/16.0] -- OF WORD], runs => [nRuns: CARDINAL, run: SEQUENCE COMPUTED CARDINAL OF Run], ENDCASE ]; Run: TYPE ~ PDFileFormat.Run; Status: TYPE ~ {disabled, readOnly, extendable, transition}; Mask: TYPE ~ REF; Transformation: TYPE ~ ImagerTransformation.Transformation; ROPE: TYPE ~ Rope.ROPE; GetStatus: PROC [waitDuringTransition: BOOLEAN _ TRUE] RETURNS [Status]; DoUnderLock: PROC [action: PROC]; Disable: PROC; MakeReadOnly: PROC; Enable: PROC; FontCacheInconsistency: ERROR [reason: ATOM, wordOffset: INT]; TransID: TYPE ~ REF TransformationCodeEntry; TransIDFromTransformation: PROC [transformation: Transformation, scanConversionType: ScanConversionType, hint: TransID _ NIL] RETURNS [TransID]; TransformationFromTransID: PROC [transID: TransID] RETURNS [Transformation]; FontID: TYPE ~ REF FontIDCodeEntry; FontIDFromRopeAndGMT: PROC [name: ROPE, createdTime: BasicTime.GMT] RETURNS [FontID]; RopeFromFontID: PROC [fontID: FontID] RETURNS [name: ROPE]; GMTFromFontID: PROC [fontID: FontID] RETURNS [createdTime: BasicTime.GMT]; InsertMask: PROC [fontID: FontID, transID: TransID, charCode: INT, sWidth, fWidth: Scaled.Value, mask: Mask, amplified, correctSpace, correctMask: BOOLEAN _ FALSE] RETURNS [ok: BOOLEAN]; MaskDesc: TYPE ~ RECORD [ref: REF, maskEntryPtr: LONG POINTER TO MaskEntry]; GetMask: UNSAFE PROC [fontID: FontID, transID: TransID, charCode: INT] RETURNS [MaskDesc]; RopeOrRefText: TYPE ~ REF; StringBodyDesc: TYPE ~ RECORD [stringBody: RopeOrRefText, start: INT _ 0, length: INT _ INT.LAST, fontSet: [0..256) _ 0]; Current: PROC [stringBodyDesc: StringBodyDesc] RETURNS [charCode: INT]; Advance: PROC [stringBodyDesc: StringBodyDesc] RETURNS [StringBodyDesc]; GetStringBodyMasks: PROC [ fontID: FontID, transID: TransID, stringBodyDesc: StringBodyDesc, maskProc: UNSAFE PROC [MaskDesc] ] RETURNS [StringBodyDesc]; TrimCache: PROC [maxNumberOfMasks: INT, maxNumberOfWords: INT]; SetMaskUsage: PROC [fontID: FontID, transID: TransID, charCode: INT, usage: CARDINAL]; Enumerate: PROC [action: PROC [FontID, TransID, MaskDesc] RETURNS [continue: BOOL]]; GetHeader: PROC RETURNS [header: Header]; GetListOfContents: PROC RETURNS [LIST OF MaskDescriptor]; MaskDescriptor: TYPE ~ RECORD[name: ROPE, transID: TransID, usage: INT, set: INT, c: CHAR]; END. άImagerMaskCache.mesa Copyright (C) 1984, 1985 by Xerox Corporation. All rights reserved. Created May 1, 1984 Michael Plass, August 23, 1984 10:32:54 am PDT Doug Wyatt, January 26, 1985 5:36:29 pm PST Overview This is the interface to the global cache of character masks. This cache lives on the local disk under the name "[]<>FontCache.dontDeleteMe". Normally at most one cache is in active use at any given time. The cache may be in one of the following states: disabled - not in use at all. readOnly - file may be open for read, but nothing will be added to the file. extendable - file is open for write; new masks may be added. (normal state) transition - moving between states. The file format consists of a fixed-length header at the beginning, a large number of variable length records, and a word of zeros as a trailer. The file format is simple enough and has enough redundancy so that it should be scavangable even if left in a somewhat inconsistent state. Since it is just a cache, it should always be correct to throw away the font cache file and start over, but in practice it may prove to be somewhat costly to rebuild it to a usable state. There is a hash table in virtual memory that maps each font/transformation/charcode to an index to the mask in the cache. This hash table is rebuilt whenever the font cache is opened, and maintained as new masks are added to the cache. Each entry in the hash table also contains a use count, which is merged back into the font cache file when it is closed; these statistics may be helpful for utilities for offline processing of the cache, such as culling rarely-used entries, grouping frequently-used entries together, or calculating bit-tuned versions of the masks. Each mask is identified by the triple [ fontID, transformation, charCode ] where fontID is a unique identifer (i.e., hierarchical name and timestamp) for the font that was the source of the mask transformation is the (affine) transformation (character coordinates => device coordinates), together with a code describing the type of scan conversion used. charCode is the 32-bit character code. The font cache file contains entries that map fontIDs and transformations onto 16-bit codes, so that the [ fontID, transformation, charCode ] identifier is 4 words long. Font Cache File Record Definitions denominator is always positive not including the prefix word The name is stored using lower-case letters, with slashes separating the components. [fMin: CARDINAL, lastRun: BOOLEAN, fSize: NAT] fMin is relative to fMinBB Font Cache Operations Calls the action procedure. Until the action procedure terminates, no other processes will be allowed to alter the status of the cache. Turns the font cache off, after completing any pending writes. Makes the cache read-only, after completing any pending writes. Updates to use counts are still allowed. Makes the cache extendable Canonicalized at creation. The codeValue field may change when the cache is trimmed. The hint may be supplied if the client has a good idea of what the id probably is. The ScanConversionType is chosen by the device. Canonicalized at creation. The codeValue field may change when the cache is trimmed. Chooses the representation. May refuse to add a mask if it is too big or if the cache is full. For safety's sake, don't drop the ref until you are done with the long pointer. Returns a NIL maskEntryPtr if the character is not in the cache or the cache is disabled. 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. Calls the maskProc for each character code in the StringBody, until the length is exhausted or until an unavailable mask is encountered. The returned StringBodyDesc will have an updated start, length, and fontSet. Flushing the cache Discards unpopular masks from the cache until the specified limits are met. Masks with zero usage are always discarded. Sets the use count - useful for controlling the flushing of the cache. Enumerates the contents of the cache. It is ok to call SetMaskUsage from the action proc. Informational procedures Returns all zeros if the cache is disabled. The list is not sorted in any particular order. ΚA˜Icode™™DK™K™.J™+—K˜šΟk ˜ Kšœ œœ˜Kšœ œ˜Kšœœ ˜Kšœœ˜,Kšœœœ˜—K˜Kšœœ ˜"Kšœ˜headšœ™K™€K™K™LK™KK™#K™™ΩK™—™ΉK™—™%K™$—™K™qK™žK™&—K™©—šœ"™"š œœœ œœœ˜GKšœ™K˜—KšœœΟf˜!š œœœ œœ˜)Kšœ  ˜Kšœœœ˜Kšœœœ˜Kšœ œ˜Kšœ˜K˜—šœ œœ ˜#Kšœ8˜8K˜—š œ œœ œœ˜.K˜šœ˜K™—Kšœ˜K˜—š œœœ œœ˜2Kšœ œ˜Kšœœ˜š œœœœœ˜-K™T—Kšœ˜K˜—š œœœ œœ˜:Kšœ œ˜K˜K˜&Kšœ˜K˜—š œœœ œœ˜5K˜2K˜)K˜Kšœœœ˜Kšœœ˜Kšœ˜K˜—šœœœ œ˜K˜—š  œœ˜K™?K™(K˜—š œœ˜ Kšœ™K˜—šœœ œœ˜>K˜—šœ œœ˜,K™K™9K˜—š œœZœœ ˜K™RKšœ/™/K˜—š œœœ˜LK˜—šœœœ˜#K™K™9K˜—š  œœœœœ ˜UK˜—š œœœœ˜;K˜—š  œœœœ˜JK˜—š  œœ.œRœœœœ˜ΊKšœ^™^K˜—š œ œœœœœœ ˜LK™OK˜—š  œœœ.œœ ˜ZKšœY™YK˜—Kšœœœ˜š œœœ$œœœœ˜yKšœΞ™ΞK˜—š œœ"œ œ˜GK˜—š œœ"œ˜HK˜—š œœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ œœ ˜ Kšœœ˜KšœΦ™ΦK˜——šœ™š  œœœœ˜?KšœK™KK™+K˜—š  œœ.œ œ˜VK™FK˜—š   œœ œœ œ˜TKšœY™YK˜——šœ™š  œœœ˜)K™+K˜—Kš  œœœœœ˜9š œœœœœœœ˜[K™/K˜——K˜Kšœ˜—…—ͺ'Η