DIRECTORY Rope, Graphics, GraphicsBasic, Scaled; UnifiedFonts: CEDAR DEFINITIONS = BEGIN ROPE: TYPE = Rope.ROPE; RopeOrRefText: TYPE = REF; Context: TYPE = Graphics.Context; FONT: TYPE = REF FontRec; Create: PROCEDURE [fontName: RopeOrRefText, transformation: Transformation _ identity, deviceType: DeviceType _ $Ideal] RETURNS [FONT]; Transformation: TYPE = RECORD [scale: REAL, rotation: REAL _ 0]; identity: Transformation = [scale: 1, rotation: 0]; DeviceType: TYPE = ATOM; EasyTransformations: PROCEDURE [fontName: RopeOrRefText, deviceType: DeviceType, transformationProc: TransformationProc]; TransformationProc: TYPE = PROCEDURE [transformation: Transformation] RETURNS [quit: BOOLEAN _ FALSE]; anyTransformation: Transformation = [scale: 0]; Name: PROCEDURE [font: FONT] RETURNS [fontName: ROPE]; Contains: PROCEDURE [font: FONT, char: CHAR] RETURNS [BOOLEAN]; NSCode: PROCEDURE [font: FONT, char: CHAR] RETURNS [nsCode: INT]; unassignedNSCode: INT = 255; nonexistentNSCode: INT = 65535; CharCode: PROCEDURE [font: FONT, nsCode: INT] RETURNS [char: CHAR]; DrawChar: PROCEDURE [font: FONT, char: CHAR, context: Context]; Direction: TYPE = {right, up, left, down}; Box: TYPE = GraphicsBasic.Box; NextCharacterDirection: PROCEDURE [font: FONT] RETURNS [Direction]; NextLineDirection: PROCEDURE [font: FONT] RETURNS [Direction]; FormattingBox: PROCEDURE [font: FONT, char: CHAR] RETURNS [Box]; Width: PROCEDURE [font: FONT, char: CHAR] RETURNS [REAL]; GetLigatureOrKern: PROCEDURE [font: FONT, char1, char2: CHAR] RETURNS [LigatureOrKern]; LigatureOrKern: TYPE = RECORD [ SELECT tag: * FROM neither => [], kern => [kernAmount: REAL], ligature => [ligatureCode: CHAR], ENDCASE]; RequestedTransformation: PROCEDURE [font: FONT] RETURNS [Transformation]; FormattingMetric: PROCEDURE [font: FONT, metric: ATOM, char: CHAR _ '\000] RETURNS [REAL]; Undefined: PROCEDURE [r: REAL] RETURNS [BOOLEAN] = TRUSTED INLINE {RETURN[LOOPHOLE[r, LONG CARDINAL]=20000000000B]}; FormattingInfo: PROCEDURE [font: FONT, name: ATOM, char: CHAR _ '\000] RETURNS [REF]; Vec: TYPE = GraphicsBasic.Vec; BoundingBox: PROCEDURE [font: FONT, char: CHAR] RETURNS [Box]; WidthVector: PROCEDURE [font: FONT, char: CHAR] RETURNS [Vec]; ActualTransformation: PROCEDURE [font: FONT] RETURNS [Transformation]; Positioning: TYPE = {rounded, exact}; DrawCharSeq: PROCEDURE [ font: FONT, context: Context, count: NAT, charPtr: LONG POINTER TO CHAR, charIncrement: NAT, deltaXptr: LONG POINTER TO FixedUnit, deltaXincrement: NAT, deltaYptr: LONG POINTER TO FixedUnit, deltaYincrement: NAT, positioning: Positioning _ rounded ]; FixedUnit: TYPE = Scaled.Value; FixedPoint: FixedUnit = Scaled.unit; WidthArray: TYPE = REF READONLY ARRAY CHAR OF FixedUnit; GetWidthArray: PROCEDURE [font: FONT, minimum, undefined: FixedUnit _ Scaled.zero] RETURNS [WidthArray]; BadFontFileFormat: ERROR; PressFontSpecification: TYPE = RECORD [ family: ROPE, face: PressFontFace, size: INTEGER, rotation: INTEGER ]; PressFontFace: TYPE = [0..256); GetPressFontSpecification: PROCEDURE [FONT] RETURNS[PressFontSpecification]; Key: TYPE = RECORD [index: NAT _ LAST[NAT]]; FontRec: TYPE = RECORD [ name: ROPE, requestedTransformation: Transformation, actualTransformation: Transformation, deviceType: DeviceType, nsCodeTable: Key, fontFormattingClass: REF FontFormattingClassRec, formattingKey: Key, cachedWidthsMinimum, cachedWidthsUndefined: FixedUnit _ Scaled.zero, cachedWidths: REF ARRAY CHAR OF FixedUnit, fontGraphicsClass: REF FontGraphicsClassRec, graphicsKey: Key, bc, ec: CHAR, contains: REF PACKED ARRAY CHAR OF BOOLEAN, fontBoundingBox: Box, bitmapCacheable: BOOLEAN, characterCache: REF, propertyList: REF, link: REF FontRec ]; pZone: ZONE; PutProp: PROCEDURE [font: FONT, name: ATOM, value: REF ANY]; GetProp: PROCEDURE [font: FONT, name: ATOM] RETURNS [value: REF ANY]; RegisterFontFormattingClass: PROCEDURE [flavor: ATOM, init: PROC [font: FONT]]; RegisterFontGraphicsClass: PROCEDURE [flavor: ATOM, init: PROC [font: FONT]]; FontFormattingClassRec: TYPE = RECORD [ formattingBoxProc: PROCEDURE [font: FONT, char: CHAR] RETURNS [box: Box], ligKernProc: PROCEDURE [font: FONT, char1, char2: CHAR] RETURNS [ligatureOrKern: LigatureOrKern], formattingMetricProc: PROCEDURE [font: FONT, metric: ATOM, char: CHAR] RETURNS [REAL] ]; FontGraphicsClassRec: TYPE = RECORD [ drawCharProc: PROCEDURE [font: FONT, char: CHAR, context: Context], boundingBoxProc: PROCEDURE [font: FONT, char: CHAR] RETURNS [box: Box], widthVectorProc: PROCEDURE [font: FONT, char: CHAR] RETURNS [vec: Vec], containsProc: PROCEDURE [font: FONT, char: CHAR] RETURNS [BOOLEAN] ]; END. UnifiedFonts.mesa Unified Font Interface Written November 1, 1982 4:21 pm Last edited by Michael Plass, February 18, 1983 9:23 am This interface is designed to be used in conjunction with CedarGraphics, and perhaps someday it will become integrated with that package. A FONT describes a font, that is, a collection of related graphical objects. Each object, or character, in the collection is referred to by an index of type CHARACTER. There are various attributes of a font that may be accessed through this interface; some of them pertain to the font as a whole, and others pertain to the individual characters. The actual graphical objects contained in a font may or may not be locally available. For hardcopy applications, the exact graphical descriptions typically reside at the print server, and cannot be assumed to be available. On the other hand, the graphical descriptions for fonts to be used on the screen must be locally available. In any case, some sort of reasonable approximation is attempted for local use. A font is ideally available in all sizes and rotations; however, not all print servers are capable of living up to this ideal. Therefore, a mechanism is provided for finding out what transformations are available (easy) for a font on a particular kind of output device. The association between CHARACTER codes and the images is often jumbled, due to historical reasons and the natural slowness in the propagation of standards. As a step towards untangling this mess, this interface provides a way to find out the Xerox Character Code for a character in a given font, and vice versa. The unit used for all metric information is the same as the default CedarGraphics unit. This gets at least the font metric information from a centralized database. The font name is an Interpress hierarchial font name, and encodes all of the family, face, and design size information. With the default transforamation, the font will be in a size designed for one-unit baseline spacing; in most applications, the scale of the transformation will be the body height that is desired. A Transformation specifies the linear transformation used to scale and rotate fonts. Only uniform scaling and rotation are supported. The rotation is given in degrees counterclockwise. Tells what kind of device to tailor the easy transformations for. $Ideal as a device type will allow any transformation. Atoms that will probably make sense here are $Ideal, $Press, $Spruce, $Screen, or the name of a print server (first letter capital, remainder lower case). EasyTransformations enumerates the transformations of the font that are easy on the specified device. If any transformation is allowed, anyTransformation will be included in the list of easy transformations. This extracts the name of the font. May return NIL if the font is unnamed. TRUE iff the character exists in the font. Returns the Network Systems code for the specified character; unassignedNSCode is returned for characters that have no such code assigned, and nonexistentNSCode is returned for characters that do not exist in the font. Returns the CHARACTER code for the specified Network Systems code; NUL is returned for characters that do not exist in the font. Displays a single character through Graphics. Formatting Metrics The following metrics use a model derived from the hand compositon of type. Each character is considered to be on a rectangular body that is always aligned with the page. The characters are not required to lie entirely within this body, or formatting box; the box is just for composition purposes. Each character has a reference point that is used to line the characters up when making a line or column of text. Placing a character at a point means to position it so that its reference point lines up with the given point. Note that the formatting metrics do not change when a font is rotated. = RECORD [xmin, ymin, xmax, ymax: REAL] Normally right for Latin alphabets. Normally down for Latin alphabets. Normally xmin is zero for Latin alphabets. Equal to FormattingBox[font, char].xmax - FormattingBox[font, char].xmin, but maybe faster. The amount to add to the character's motion to kern this character to the successor character. Escape hatch for getting metrics not included above. Returns Real.MinusZero if the metric is not available for the particular font. Escape hatches for getting other information not included above. Returns NIL if the information is not available for the particular font. Graphical Metrics These metrics are provided to tell the client what will happen when the character is drawn. Unlike the formatting metrics, these will change if the font is rotated. = RECORD [x, y: REAL] A true bounding box for the character mask, not necessarily as tight as possible. Tells how the current position is changed when the character is drawn. Tells the transformation after any font substitution is done. Provisions for speedy display Displays a batch of characters. Use this where speed is important. There are exactly 72*FixedPoint FixedUnits per inch. Gives the formatting widths in fixed-point form. Errors Press Compatibility Stuff Implementor Private Stuff Formatting metrics stuff. Graphics object stuff. This is to store font-related things that are typically allocated once and held onto for a long time. Mostly for internal use. ΚJ˜Jšœ)™)Jšœ ™ J™7IunitšΟk œ'˜0šœœ œ˜!Jš˜Jšœœœ˜Jšœœœ˜Jšœ œ˜!Jšœ‰™‰KšΠlnœœœ ˜JšœΫ™ΫJšœœ™œJšœŽ™ŽJšœΉ™ΉJ™WšΟnœ œgœœ˜‡Jšœ‰™‰—Kš žœœœ œ œ˜@JšœΊ™ΊKšœ3˜3šž œœœ˜Jšœ–™–—šŸœ œ[˜yKš Ÿœœ œ"œœœ˜fIcodešœ/˜/JšŸœvŸœ6™Π—š Ÿœ œœœ œ˜6JšœK™K—š Ÿœ œœœœœ˜?Jšœ*™*—š Ÿœ œœœœ œ˜ALšœœ˜Lšœœ ˜Jšœ>ΟbœA œ:™Ϊ—š Ÿœ œœ œœœ˜CJšœ  œk™€—šŸœ œœœ˜?JšΟcœ™-—headš‘™Jšœ±  œ™ΦKšœ œ˜*šœœ˜Jš œœ™'—šŸœ œœœ ˜CJšœ  œ™#—šŸœ œœœ ˜>Jšœ  œ™"—š Ÿ œ œœœœ˜@Jšœ  œ™*—š Ÿœ œœœœœ˜9Jšœ[™[—šŸœ œœœ˜=Lšœ˜šŸœœœ˜Lšœ˜L˜šœœ˜L™^—Lšœœ˜!Lšœ˜ ——KšŸœ œœœ˜IšŸœ œœ œœ œœ˜ZJ™„—KšŸ œ œœœœœœœœœœ˜tšŸœ œœœœ œœ˜UJ™Š——š‘™Jšœ₯™₯šœœ˜Jš œœ™—š Ÿ œ œœœœ˜>JšœQ™Q—š Ÿ œ œœœœ˜>JšœF™F—šŸœ œœœ˜FJšœ=™=——š‘™Kšœ œ˜%šŸ œ œ˜Jšœœœ˜*Jš œ œœœœœ˜2Jš œ œœœœ˜;Jš œ œœœœ˜;Jšœ"˜"Jšœ˜Jš‘Bœ™C—Kšœ œ˜šœ$˜$Jšœ4™4—Kš œ œœœœœœ ˜8šŸ œ œœ/œ˜hJ™0——š‘™KšŸœœ˜—š‘™šŸœœœ˜(Lšœœ˜ Lšœ˜Lšœœ˜Lšœ ˜L˜—KšŸ œœ ˜KšŸœ œœœ˜L—š‘™Kš œœœ œœœ˜,šœ œœ˜Lšœœ˜ Lšœ(˜(Lšœ%˜%Lšœ˜Lšœ˜šœ™Lšœœ˜0Lšœ˜LšœD˜DLš œœœœœ ˜*—™Lšœœ˜,Lšœ˜Lšœœ˜ Lš œ œœœœœœ˜+L˜—Lšœœ˜Lšœœ˜Lšœœ˜Lšœœ˜L˜—šœœ˜ Idefault™—Kš Ÿœ œœœ œœ˜