DIRECTORY Ascii, Char, Imager, ImagerFont, ImagerPrivate, ImagerTransformation, IO, Prop, RefTab, Rope, ImagerXCMap; ImagerXCFontMapImpl: CEDAR PROGRAM IMPORTS Char, Imager, ImagerFont, ImagerTransformation, IO, Prop, RefTab, Rope, ImagerXCMap EXPORTS Imager, ImagerXCMap ~ BEGIN OPEN ImagerXCMap; Class: TYPE ~ ImagerPrivate.Class; ClassRep: PUBLIC TYPE ~ ImagerPrivate.ClassRep; -- export to Imager BoundOutputMap: TYPE ~ REF BoundOutputMapRep; BoundOutputMapRep: TYPE ~ RECORD [newFont: ImagerFont.Font, map: Map]; Data: TYPE ~ REF DataRep; DataRep: TYPE ~ RECORD[ c: Imager.Context, curFont: ImagerFont.Font ¬ NIL, curBoundOutputMap: BoundOutputMap ¬ NIL, curMappedFont: ImagerFont.Font ¬ NIL, fontMap: FontMap, fontTable: RefTab.Ref, -- maps ImagerFont.Font to REF FontMapEntry saveStack: LIST OF SaveEntry, msg: IO.STREAM, verbose: BOOL ]; SaveEntry: TYPE ~ RECORD [ curFont: ImagerFont.Font, curBoundOutputMap: BoundOutputMap, curMappedFont: ImagerFont.Font, ref: REF ]; FilterFonts: PUBLIC PROC [c: Imager.Context, fontMap: FontMap, msg: IO.STREAM, verbose: BOOL] RETURNS [context: Imager.Context] ~ { oldClass: Class ~ c.class; data: Data ~ NEW[DataRep ¬ [c: c, fontMap: fontMap, fontTable: RefTab.Create[], msg: msg, verbose: verbose]]; props: Prop.PropList ~ Prop.Put[c.propList, $ImagerXCMapFilter, data]; class: Class ~ NEW[ClassRep ¬ oldClass­]; class.type ¬ $ImagerXCMapFilter; class.Save ¬ MySave; class.Restore ¬ MyRestore; class.SetFont ¬ MySetFont; class.GetFont ¬ MyGetFont; class.Show ¬ MyShow; class.ShowText ¬ MyShowText; context ¬ NEW[Imager.ContextRep ¬ [class: class, state: c.state, data: c.data, propList: props]]; }; MySetFont: PROC[context: Imager.Context, font: ImagerFont.Font] ~ { data: Data ~ NARROW[Imager.GetProp[context, $ImagerXCMapFilter]]; subst: BoundOutputMap ¬ NARROW[data.fontTable.Fetch[font].val]; IF subst = NIL THEN { oldName: Rope.ROPE ~ ImagerFont.Name[font]; fme: FontMapEntry; newFont: ImagerFont.Font; canPrint: BOOL ~ data.msg#NIL; printing: BOOL ¬ canPrint AND data.verbose; FOR p: FontMap ¬ data.fontMap, p.rest UNTIL p=NIL DO IF Rope.Equal[oldName, p.first.inputName, FALSE] THEN { fme ¬ p.first; EXIT; }; REPEAT FINISHED => fme ¬ [inputName: oldName, outputName: oldName, map: cs0Map, scale: 1.0, warn: FALSE]; ENDLOOP; IF fme.warn AND canPrint THEN printing ¬ TRUE; IF fme.warn AND printing THEN data.msg.PutRope[" WARNING:"]; IF printing THEN data.msg.PutF[" (%g =>%g", IO.rope[oldName], IO.rope[fme.outputName]]; newFont ¬ ImagerFont.Find[fme.outputName ! Imager.Warning => {IF printing THEN data.msg.PutF1[" {%g}", IO.rope[error.explanation]]; RESUME}]; newFont ¬ ImagerFont.Modify[newFont, ImagerTransformation.PostScale[font.charToClient, fme.scale]]; IF printing THEN data.msg.PutRope[")"]; subst ¬ NEW [BoundOutputMapRep ¬ [newFont, fme.map]]; [] ¬ data.fontTable.Store[font, subst]; }; data.curFont ¬ font; IF subst = NIL THEN ERROR; IF data.curMappedFont#subst.newFont THEN { Imager.SetFont[data.c, subst.newFont]; data.curMappedFont ¬ subst.newFont; }; data.curBoundOutputMap ¬ subst; }; MyShow: PROC[context: Imager.Context, string: ImagerFont.XStringProc, xrel: BOOL] ~ { myString: ImagerFont.XStringProc ~ { myCharAction: ImagerFont.XCharProc ~ { IF Char.Set[char]=0 THEN char ¬ data.curBoundOutputMap.map[VAL[Char.Code[char]]]; charAction[char]; }; string[myCharAction]; }; data: Data ~ NARROW[Imager.GetProp[context, $ImagerXCMapFilter]]; Imager.Show[data.c, myString, xrel]; }; MyShowText: PROC [context: Imager.Context, text: REF READONLY TEXT, start, len: NAT, xrel: BOOL] ~ { string: ImagerFont.XStringProc ~ { ImagerFont.MapText[text, start, len, charAction] }; Imager.Show[context, string, xrel]; }; MySave: PROC[context: Imager.Context, all: BOOL] RETURNS [REF] ~ { data: Data ~ NARROW[Imager.GetProp[context, $FontFilter]]; cClass: Class ~ data.c.class; data.saveStack ¬ CONS[[ curFont: data.curFont, curBoundOutputMap: data.curBoundOutputMap, curMappedFont: data.curMappedFont, ref: cClass.Save[context, all] ], data.saveStack]; RETURN [data.saveStack] }; MyRestore: PROC[context: Imager.Context, ref: REF] ~ { data: Data ~ NARROW[Imager.GetProp[context, $FontFilter]]; cClass: Class ~ data.c.class; IF NOT (ref=NIL OR ref = data.saveStack) THEN ERROR; cClass.Restore[context, data.saveStack.first.ref]; data.curMappedFont ¬ data.saveStack.first.curMappedFont; data.curBoundOutputMap ¬ data.saveStack.first.curBoundOutputMap; data.curFont ¬ data.saveStack.first.curFont; data.saveStack ¬ data.saveStack.rest; }; MyGetFont: PROC[context: Imager.Context] RETURNS[ImagerFont.Font] ~ { data: Data ~ NARROW[Imager.GetProp[context, $ImagerXCMapFilter]]; RETURN [data.curFont] }; tiogaToXC: PUBLIC FontMap; -- maps Tioga fonts to XC equivalents pressToXC: PUBLIC FontMap; -- maps Press fonts to XC equivalents tiogaAndPressToXC: PUBLIC FontMap; -- maps Tioga & Press fonts to XC equivalents Face: TYPE = RECORD [source, dest: Rope.ROPE]; TiogaMapping: TYPE ~ RECORD [family: Rope.ROPE, sizes: LIST OF NAT, target: Rope.ROPE]; tiogaMappings: LIST OF TiogaMapping ¬ LIST [ ["AMTeX", LIST [10], "Terminal"], ["APL", LIST [14], "Classic"], ["Asterisk", LIST [10], "Modern"], ["Classic", LIST [8, 10, 12, 14], "Classic"], ["Cream", LIST [10, 12], "Modern"], ["Cyrillic", LIST [10, 12], "Classic"], ["EightBitTimesRoman", LIST [10], "TimesRoman"], ["Gacha", LIST [8, 10, 12], "Terminal"], ["Hebrew", LIST [14], "Classic"], ["Helvetica", LIST [6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18], "Helvetica"], ["Hippo", LIST [8, 10, 12, 18], "Classic"], ["Logo", LIST [12, 14, 18, 20, 24, 26], "Logotypes-Xerox"], ["Math", LIST [8, 10, 12], "Classic"], ["OldEnglish", LIST [10, 18], "Classic"], ["ReverseGacha", LIST [10], "Terminal"], ["Sail", LIST [10, 12], "Classic"], ["TimesRoman", LIST [8, 9, 10, 11, 12, 13, 14, 16, 18], "TimesRoman"], ["Tioga", LIST [10], "Classic"], ["XeroxLogotypes", LIST [48], "Logotypes-Xerox"]]; tiogaFaces: LIST OF Face ¬ LIST [ ["", ""], ["I", "-italic"], ["B", "-bold"], ["BI", "-bold-italic"] ]; PressMapping: TYPE ~ RECORD [family: Rope.ROPE, target: Rope.ROPE]; pressMappings: LIST OF PressMapping ¬ LIST [ ["Classic", "Classic"], ["ClassicPiOne", "Classic"], ["Gacha", "Terminal"], ["Helvetica", "Helvetica"], ["Hippo", "Classic"], ["Laurel", "Classic"], ["Math", "Classic"], ["Modern", "Modern"], ["ModernPiOne", "Modern"], ["OldEnglish", "Classic"], ["TimesRoman", "TimesRoman"], ["XeroxBook", "Terminal"], ["XeroxLogotypes", "Logotypes-Xerox"]]; pressFaces: LIST OF Face ¬ LIST [ ["-mrr", ""], ["-mir", "-italic"], ["-brr", "-bold"], ["-bir", "-bold-italic"] ]; InitFontMaps: PROC [] RETURNS [] ~ { tiogaToXC ¬ NIL; FOR tms: LIST OF TiogaMapping ¬ tiogaMappings, tms.rest UNTIL tms=NIL DO map: Map ¬ GetFamilyMap[tms.first.family]; FOR faces: LIST OF Face ¬ tiogaFaces, faces.rest UNTIL faces=NIL DO dest: Rope.ROPE ¬ IO.PutFR["Xerox/XC1-2-2/%g%g", IO.rope[tms.first.target], IO.rope[faces.first.dest]]; FOR sizes: LIST OF NAT ¬ tms.first.sizes, sizes.rest UNTIL sizes=NIL DO source: Rope.ROPE ¬ IO.PutFR["Xerox/TiogaFonts/%g%g%g", IO.rope[tms.first.family], IO.int[sizes.first], IO.rope[faces.first.source]]; tiogaToXC ¬ CONS [ [inputName: source, outputName: dest, map: map, scale: sizes.first, warn: FALSE], tiogaToXC]; ENDLOOP; ENDLOOP; ENDLOOP; pressToXC ¬ NIL; FOR tms: LIST OF PressMapping ¬ pressMappings, tms.rest UNTIL tms=NIL DO map: Map ¬ GetFamilyMap[tms.first.family]; FOR faces: LIST OF Face ¬ tiogaFaces, faces.rest UNTIL faces=NIL DO dest: Rope.ROPE ¬ IO.PutFR["Xerox/XC1-2-2/%g%g", IO.rope[tms.first.target], IO.rope[faces.first.dest]]; source: Rope.ROPE ¬ IO.PutFR["Xerox/PressFonts/%g%g", IO.rope[tms.first.family], IO.rope[faces.first.source]]; pressToXC ¬ CONS [ [inputName: source, outputName: dest, map: map, scale: 1.0, warn: FALSE], pressToXC]; ENDLOOP; ENDLOOP; tiogaAndPressToXC ¬ NIL; FOR fm: FontMap ¬ tiogaToXC, fm.rest UNTIL fm=NIL DO tiogaAndPressToXC ¬ CONS [fm.first, tiogaAndPressToXC]; ENDLOOP; FOR fm: FontMap ¬ pressToXC, fm.rest UNTIL fm=NIL DO tiogaAndPressToXC ¬ CONS [fm.first, tiogaAndPressToXC]; ENDLOOP; }; InitFontMaps[]; END. Κ ImagerXCFontMapImpl.mesa Copyright Σ 1987, 1992 by Xerox Corporation. All rights reserved. Jean-Marc Frailong February 4, 1988 7:15:23 pm PST Michael Plass, September 15, 1989 1:18:23 pm PDT Provides font substitution for Tioga & Press fonts Implementation is split because of compiler storage overflow. Willie-s, April 6, 1992 12:58 pm PDT Filtering imager context FontMap initialization Create tiogaToXC Create pressToXC Create tiogaAndPressToXC Κ C–(cedarcode) style•NewlineDelimiter ™codešœ™Kšœ Οeœ7™BK™2K™0K™K™2K™=K™$K™—šΟk ˜ KšœFžœ"˜j—K˜KšΠblœžœž˜"Kšžœ1žœ!˜[Kšžœ˜Kšœž œ ž˜head™Kšœžœ˜"šœ žœžœΟc˜CK˜—Kšœžœžœ˜-šœžœžœ&˜FK˜—Kšœžœžœ ˜šœ žœžœ˜Kšœ˜Kšœžœ˜Kšœ$žœ˜(Kšœ!žœ˜%Kšœ˜Kšœ +˜BKšœ žœžœ ˜Kšœžœžœ˜Kšœ ž˜ Kšœ˜K˜—šœ žœžœ˜Kšœ˜Kšœ"˜"Kšœ˜Kšœž˜Kšœ˜K˜—šΟn œžœžœ,žœžœ žœžœ˜ƒKšœ˜Kšœ žœ]˜mKšœF˜FKšœžœ˜)K˜ K˜K˜K˜K˜K˜K˜Kšœ žœT˜aKšœ˜K˜—š‘ œžœ4˜CKšœ žœ.˜AKšœžœ!˜?šžœ žœžœ˜Kšœžœ˜+Kšœ˜Kšœ˜Kšœ žœ žœ˜Kšœ žœ žœ˜+šžœ#žœžœž˜4šžœ(žœžœ˜7K˜Kšžœ˜Kšœ˜—šž˜KšžœSžœ˜b—Kšžœ˜—Kšžœ žœ žœ žœ˜.Kšžœ žœ žœ˜