%! % Date: Sun, 20 Mar 88 01:16:14 EST % To: NeWS-makers@brillig.umd.edu % Subject: Re: How to properly scale fonts in an application? % From: Don Hopkins % Sender: NeWS-makers-request@brillig.umd.edu (Don Hopkins) % % Here's one way to get fonts to come out the right size when using a % funky coordinate system in PostScript. The trick is to save away the % matrix appropriate for showing the font, set up the funky coordinate % system, move to where you want to show the text, use setmatrix to get % back in the font coordinate system, and then show the string! (This % code is for NeWS, but the concept applies to any PostScript system, of % course.) Thanks to Steve Isaac for showing me this trick! % % -Don % % Example of how to get the right font size when changing the % coordinate system in PostScript. % /win framebuffer /new DefaultWindow send def { /PaintClient { gsave % Step onto the drawing surface! ClientCanvas setcanvas % (implies initmatrix) % Set the font to the appropriate size, in the canvas's default % coordinate system. /Times-Roman findfont 24 scalefont setfont % Get a copy of the canvas's matrix on the stack. matrix currentmatrix % CanvasMatrix % Scale the coordinate system to the unit square in the window. % Lower left = (0,0), upper right = (1,1). clippath pathbbox scale pop pop % Move to where we want to show the string (the center of the % window) in our "interesting" coordinate system. .5 .5 moveto % Now that we're there, we can go back to the coordinate system % that our font's expecting to be shown in. setmatrix % % Show the string at the right size in the window center! (<=(.5,.5)) show grestore } def } win send /reshapefromuser win send /map win send