DIRECTORY UnifiedFonts, ViewerClasses, ViewerOps, Graphics, GraphicsColor, Rope, Real; UFSample: CEDAR PROGRAM IMPORTS UnifiedFonts, ViewerOps, Graphics, GraphicsColor, Rope, Real = BEGIN ComplexNumber: TYPE = RECORD [x,y: REAL]; ComplexMul: PROCEDURE [a, b: ComplexNumber] RETURNS [ComplexNumber] = {RETURN[[(a.x*b.x - a.y*b.y), (a.x*b.y + a.y*b.x)]]}; Create: PROCEDURE RETURNS [viewer: ViewerClasses.Viewer] = TRUSTED { viewer _ ViewerOps.CreateViewer[flavor: $UFSampler, info: [name: "Font Sampler"], paint: TRUE]; }; baseline: NAT _ 40; scale: REAL _ 1.0; indent: NAT _ 6; text: Rope.ROPE _ "Quick brown fox, jump over the lazy dogs."; defaultFontName: Rope.ROPE _ "Xerox/NS/Times/italic/body"; defaultSize: REAL _ 10.0; defaultRotation: REAL _ 0; drawingBoundingBoxes, drawingDesignBoxes, drawingWidths: BOOLEAN _ FALSE; boundingBoxColor: Graphics.Color _ GraphicsColor.HSVToColor[.1, .7, .85]; designBoxColor: Graphics.Color _ GraphicsColor.HSVToColor[.8, .6, .4]; widthVectorColor: Graphics.Color _ GraphicsColor.HSVToColor[.6, .6, .1]; font: UnifiedFonts.FONT; viewer: ViewerClasses.Viewer; path: Graphics.Path _ Graphics.NewPath[5]; deviceType: ATOM _ $Ideal; Font: PROC [fontName: Rope.ROPE, size: REAL _ -1.0, rotation: REAL _ -360.0] = { IF fontName.Length[]=0 THEN fontName _ defaultFontName; defaultFontName _ fontName; IF size=-1.0 THEN size _ defaultSize; defaultSize _ size; IF rotation=-360.0 THEN rotation _ defaultRotation; defaultRotation _ rotation; font _ UnifiedFonts.Create[fontName, [size, rotation], deviceType]; TRUSTED {ViewerOps.PaintViewer[viewer, client]}; }; SamplePaint: ViewerClasses.PaintProc = { paintChar: PROC [c: CHAR] RETURNS [quit: BOOL _ FALSE] = { IF drawingBoundingBoxes THEN { mark: Graphics.Mark _ Graphics.Save[context]; Graphics.SetColor[context, boundingBoxColor]; Graphics.Translate[context, Graphics.GetCP[context].x, Graphics.GetCP[context].y]; Graphics.DrawBox[context, font.BoundingBox[c]]; Graphics.Restore[context, mark]; }; IF drawingDesignBoxes THEN { box: Graphics.Box _ font.FormattingBox[c]; mark: Graphics.Mark _ Graphics.Save[context]; Graphics.SetColor[context, designBoxColor]; Graphics.Translate[context, Graphics.GetCP[context].x, Graphics.GetCP[context].y]; Graphics.Rotate[context, defaultRotation]; BEGIN OPEN box; Graphics.SetCP[context, xmin, 0]; Graphics.DrawTo[context, xmin+.55, 0]; Graphics.SetCP[context, xmin, 0]; Graphics.DrawTo[context, xmin, ymin]; Graphics.DrawTo[context, xmax, ymin]; Graphics.DrawTo[context, xmax, 0]; Graphics.DrawTo[context, xmax-0.55, 0]; Graphics.SetCP[context, xmax, 0]; Graphics.DrawTo[context, xmax, ymax]; Graphics.DrawTo[context, xmin, ymax]; Graphics.DrawTo[context, xmin, 0]; Graphics.Restore[context, mark]; END; }; Graphics.SetColor[context, Graphics.black]; font.DrawChar[c, context]; IF drawingWidths THEN { w,d,e: ComplexNumber; wx, wy, s: REAL; mark: Graphics.Mark _ Graphics.Save[context]; [[wx, wy]] _ font.WidthVector[c]; s _ Real.SqRt[wx*wx+wy*wy]/2; Graphics.Translate[context, Graphics.GetCP[context].x, Graphics.GetCP[context].y]; Graphics.FlushPath[path]; Graphics.MoveTo[path, -wx, -wy]; Graphics.DrawStroke[context, path, IF scale>5 THEN 10/scale ELSE 2, FALSE, round]; Graphics.LineTo[path, 0, 0]; Graphics.DrawStroke[context, path, 0, FALSE, round]; Graphics.FlushPath[path]; w _ [-wx/s, -wy/s]; d _ ComplexMul[w,[1,1]]; e _ ComplexMul[w,[1,-1]]; Graphics.MoveTo[path, d.x, d.y]; Graphics.LineTo[path, 0, 0]; Graphics.LineTo[path, e.x, e.y]; Graphics.DrawStroke[context, path, 0, FALSE, round]; Graphics.Restore[context, mark]; }; }; IF NOT clear THEN { Graphics.SetColor[context, Graphics.white]; Graphics.DrawBox[context, [-100000, -100000, 100000, 100000]]; }; Graphics.Translate[context, indent, self.ch]; Graphics.Scale[context, scale, scale]; Graphics.Translate[context, 0, -baseline]; Graphics.SetCP[context, 0, 0]; IF font # NIL THEN [] _ Rope.Map[base: text, action: paintChar]; }; samplerClass: ViewerClasses.ViewerClass _ NEW[ViewerClasses.ViewerClassRec _ [ paint: SamplePaint, tipTable: NIL ]]; TRUSTED {ViewerOps.RegisterViewerClass[$UFSampler, samplerClass]}; viewer _ Create[]; END. RUFSample.mesa Created January 18, 1983 Michael Plass, March 2, 1983 1:04 pm ΚΤ˜J™ J™J™$IunitšΟk œM˜Všœ  ˜Jšœ=˜DJšœ˜Kšœœœœ˜)KšΟn œ œœœ.˜{šžœ œœ"œ˜DJšœYœ˜_J˜—Kšœ œ˜Jšœœ˜Jšœœ˜Jšœ œ/˜>Jšœœ ˜:Jšœ œ˜Jšœœ˜Jšœ9œœ˜IJšœI˜IJšœF˜FJšœH˜HJšœœ˜Jšœ˜J˜*Jšœ œ ˜š žœœœœœ˜PJšœœ˜7Jšœ˜Jšœ œ˜%Jšœ˜Jšœœ˜3Jšœ˜JšœC˜CJšœ)˜0Jšœ˜—šž œ˜(š œ œœœœœ˜:šœœ˜J˜-Jšœ-˜-JšœR˜RJšœ/˜/Jšœ ˜ J˜—šœœ˜Jšœ*˜*J˜-Jšœ+˜+JšœR˜RJšœ*˜*šœœ˜Jšœ!˜!Jšœ&˜&Jšœ!˜!Jšœ%˜%Jšœ%˜%Jšœ"˜"Jšœ'˜'Jšœ!˜!Jšœ%˜%Jšœ%˜%Jšœ"˜"Jšœ ˜ Jšœ˜—J˜—Jšœ+˜+Jšœ˜šœœ˜Jšœ˜Jšœ œ˜J˜-Jšœ!˜!Jšœ˜JšœR˜RJšœ˜Jšœ ˜ Jš œ#œ œ œœ ˜RJšœ˜Jšœ&œ ˜4Jšœ˜JšœF˜FJšœ ˜ Jšœ˜Jšœ ˜ Jšœ&œ ˜4Jšœ ˜ J˜—Jšœ˜—šœœœ˜Jšœ+˜+Jšœ>˜>J˜—Jšœ-˜-Jšœ&˜&Jšœ*˜*Jšœ˜Jšœœœ.˜@Jšœ˜—šœ*œ!˜NJšœ˜Jšœ ˜ J˜—Kšœ;˜BKšœ˜Kšœ˜——…—$J