DIRECTORY Imager USING [ConcatT, Context, DoSave], ImagerFont USING [CorrectionType, Extents, Font, FontRep, nullXChar, XChar], ImagerFontPrivate USING [FontImpl, FontImplRep], ImagerTransformation USING [Scale, Transformation, TransformVec], ImagerTypeface USING [Typeface, TypefaceClass, TypefaceClassRep, TypefaceRep], IPImager, IPInterpreter, Vector2 USING [VEC]; IPTypefaceImpl: CEDAR PROGRAM IMPORTS Imager, ImagerTransformation, IPImager, IPInterpreter EXPORTS ImagerFont, IPImager ~ BEGIN OPEN IPInterpreter, ImagerTypeface, ImagerFont; VEC: TYPE ~ Vector2.VEC; Transformation: TYPE ~ ImagerTransformation.Transformation; Data: TYPE ~ REF DataRep; DataRep: TYPE ~ RECORD[ fontDescription: Vector, characterMasks: Vector, characterMetrics: Vector, transformation: Transformation, interpreter: Ref ]; Font: TYPE ~ ImagerFont.Font; FontRep: TYPE ~ ImagerFont.FontRep; FontImpl: TYPE ~ ImagerFontPrivate.FontImpl; FontImplRep: PUBLIC TYPE ~ ImagerFontPrivate.FontImplRep; -- export to ImagerFont identity: Transformation ~ ImagerTransformation.Scale[1]; MakeFont: PUBLIC PROC [self: Ref, v: Vector] RETURNS [Font] ~ { typeface: Typeface ~ IPCreate[self, v]; impl: FontImpl ~ NEW[FontImplRep _ [typeface: typeface]]; font: Font ~ NEW[FontRep _ [name: typeface.name, charToClient: identity, impl: impl]]; RETURN[font]; }; IPCreate: PROC [self: Ref, fd: Vector] RETURNS [Typeface] ~ { data: Data ~ NEW[DataRep _ []]; data.fontDescription _ fd; data.characterMasks _ VectorFromAny[GetPR[fd, "characterMasks"]]; data.characterMetrics _ VectorFromAny[GetPR[fd, "characterMetrics"]]; WITH GetPR[fd, "transformation"] SELECT FROM m: Transformation => data.transformation _ m; ENDCASE => ERROR; data.interpreter _ self; RETURN[NEW[TypefaceRep _ [class: ipClass, data: data]]]; }; IPContains: PROC [self: Typeface, char: XChar] RETURNS [BOOL] ~ { data: Data ~ NARROW[self.data]; i: Cardinal ~ LOOPHOLE[char, CARDINAL]; RETURN[GetPropC[data.characterMetrics, i].found]; }; IPNextChar: PROC [self: Typeface, char: XChar] RETURNS [next: XChar] ~ { ichar: CARDINAL ~ LOOPHOLE[char]; start: CARDINAL _ 0; IF char=nullXChar THEN start _ 0 ELSE IF ichar RETURN[mask]; 1 => RETURN[space]; ENDCASE; }; RETURN[none]; }; IPBoundingBox: PROC [self: Typeface, char: XChar] RETURNS [Extents] ~ { data: Data ~ NARROW[self.data]; found: BOOL; value: Any; [found, value] _ GetPropC[data.characterMetrics, LOOPHOLE[char, CARDINAL]]; IF found THEN { metrics: Vector ~ VectorFromAny[value]; extents: Extents _ [0, 0, 0, 0]; [found, value] _ GetPropR[metrics, "leftExtent"]; IF found THEN extents.leftExtent _ RealFromAny[value]; [found, value] _ GetPropR[metrics, "rightExtent"]; IF found THEN extents.rightExtent _ RealFromAny[value]; [found, value] _ GetPropR[metrics, "ascent"]; IF found THEN extents.ascent _ RealFromAny[value]; [found, value] _ GetPropR[metrics, "descent"]; IF found THEN extents.descent _ RealFromAny[value]; RETURN[extents]; }; RETURN[[0, 0, 0, 0]]; }; IPFontBoundingBox: PROC [self: Typeface] RETURNS [Extents] ~ { RETURN[[0, 0, 0, 0]]; }; IPKern: PROC [self: Typeface, char, successor: XChar] RETURNS [VEC] ~ { RETURN[[0, 0]]; }; IPNextKern: PROC [self: Typeface, char, successor: XChar] RETURNS [XChar] ~ { RETURN[nullXChar]; }; IPLigature: PROC [self: Typeface, char, successor: XChar] RETURNS [XChar] ~ { RETURN[nullXChar]; }; IPNextLigature: PROC [self: Typeface, char, successor: XChar] RETURNS [XChar] ~ { RETURN[nullXChar]; }; IPMask: PROC [self: Typeface, char: XChar, context: Imager.Context] ~ { data: Data ~ NARROW[self.data]; interpreter: IPInterpreter.Ref ~ data.interpreter; savedImager: Imager.Context ~ interpreter.imager; maskAction: PROC ~ { Imager.ConcatT[context, data.transformation]; IPImager.MaskChar[interpreter, data.fontDescription, LOOPHOLE[char, CARDINAL]]; }; interpreter.imager _ context; Imager.DoSave[context, maskAction ! UNWIND => interpreter.imager _ savedImager]; interpreter.imager _ savedImager; }; ipClass: TypefaceClass ~ NEW[TypefaceClassRep _ [ type: $IP, Contains: IPContains, NextChar: IPNextChar, Escapement: IPEscapement, Amplified: IPAmplified, Correction: IPCorrection, BoundingBox: IPBoundingBox, FontBoundingBox: IPFontBoundingBox, Ligature: IPLigature, NextLigature: IPNextLigature, Kern: IPKern, NextKern: IPNextKern, Mask: IPMask ]]; END. ŒIPTypefaceImpl.mesa Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. Doug Wyatt, November 21, 1985 5:34:18 pm PST ʸ˜codešœ™Kšœ Ïmœ7™BK™,—K™šÏk ˜ Kšœžœ˜(Kšœ žœ<˜LKšœžœ˜0Kšœžœ'˜AKšœžœ:˜NKšœ ˜ Kšœ˜Kšœžœžœ˜—K˜KšÐblœžœž˜Kšžœ6˜=Kšžœ˜Kšœžœžœ+˜7K˜Kšžœžœ žœ˜Kšœžœ'˜;K˜Kšœžœžœ ˜šœ žœžœ˜K˜K˜K˜K˜K˜K˜K˜—K˜Kšœžœ˜Kšœ žœ˜#Kšœ žœ˜,Kšœ žœžœ"Ïc˜QK˜9K˜šÏnœžœžœžœ ˜?K˜'Kšœžœ%˜9Kšœ žœF˜VKšžœ˜ K˜K˜—š¡œžœžœ˜=Kšœ žœ˜Kšœ˜KšœA˜AKšœE˜Ešžœžœž˜,Kšœ-˜-Kšžœžœ˜—K˜Kšžœžœ.˜8K˜K˜—š¡ œžœžœžœ˜AKšœ žœ ˜Kšœžœžœ˜'Kšžœ+˜1K˜K˜—š¡ œžœžœ˜HKšœžœžœ˜!Kšœžœ˜Kšžœžœ ˜ Kš žœžœžœžœžœ˜1Kšžœžœ ˜š žœžœžœžœžœž˜/Kšœžœ˜Kšžœžœžœ˜.Kšžœ˜—Kšžœ ˜K˜K˜—š¡ œžœžœžœ˜BKšœ žœ ˜Kšœžœ ˜Kšœ1žœžœ˜Kšžœžœ˜K˜'Kšœžœ˜K˜2Kšžœžœ˜&K˜2Kšžœžœ˜&Kšžœ-˜3K˜—Kšžœ ˜K˜K˜—š¡ œžœžœžœ˜BKšœ žœ ˜Kšœžœ ˜Kšœ1žœžœ˜Kšžœžœ˜K˜'K˜0Kšžœžœžœ˜/K˜—Kšžœžœ˜K˜K˜—š¡ œžœžœ˜MKšœ žœ ˜Kšœžœ ˜Kšœ1žœžœ˜Kšžœžœ˜K˜'K˜1šžœžœžœž˜0Kšœžœ˜Kšœžœ˜Kšžœ˜—K˜—Kšžœ˜ K˜K˜—š¡ œžœžœ˜GKšœ žœ ˜Kšœžœ ˜Kšœ1žœžœ˜Kšžœžœ˜K˜'K˜ K˜1Kšžœžœ)˜6K˜2Kšžœžœ*˜7K˜-Kšžœžœ%˜2K˜.Kšžœžœ&˜3Kšžœ ˜K˜—Kšžœ˜K˜K˜—š¡œžœžœ˜>Kšžœ˜K˜K˜—š¡œžœ*žœžœ˜GKšžœ ˜K˜K˜—š¡ œžœ*žœ ˜MKšžœ ˜K˜K˜—š¡ œžœ*žœ ˜MKšžœ ˜K˜K˜—š¡œžœ*žœ ˜QKšžœ ˜K˜K˜—š¡œžœ;˜GKšœ žœ ˜Kšœ2˜2Kšœ1˜1šœ žœ˜K˜-Kšœ5žœžœ˜OK˜—Kšœ˜Kšœ$žœ&˜PKšœ!˜!K˜K˜—K˜šœžœ˜1K˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ#˜#Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ ˜ K˜K˜—Kšžœ˜—…—®ò