Path: utzoo!mnetor!uunet!husc6!mailrus!ames!pasteur!ucbvax!BRILLIG.UMD.EDU!don From: don@BRILLIG.UMD.EDU (Don Hopkins) Newsgroups: comp.windows.news Subject: Re: How to properly scale fonts in an application? Message-ID: <8803200615.AA05440@brillig.umd.edu> Date: 20 Mar 88 06:16:14 GMT Sender: usenet@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 46 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 ====Cut here: 8X======================================================== %!/bin/psh % % 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