sun@me.utoronto.ca (Andy Sun Anu-guest) (11/11/90)
Hi, This might be a trivial question to ask but I just couldn't find the answer on the red and blue book. Is there a command to return the current scale factor a font used in scalefont? Or better, is there a command that will return the curent height of a font? My faith in PostScript tells me that if they have stringwidth, they should have something like stringheight, but I couldn't find anything similar. I am writing something that needs to know the maximum character height of a scaled font. Ideally I want to get the maximum height of a string of a particular font, which is a local maximum depending on the characters (i.e. aero will have a smaller font height than AERO). Right now I am defining the scale explictly as a variable so that I can refer to it later but that's not flexible/intelligent enough to do the job. Any help will be appreciated. Andy _______________________________________________________________________________ Andy Sun | Internet: sun@me.utoronto.ca University of Toronto, Canada | UUCP : ...!utai!me!sun Dept. of Mechanical Engineering | BITNET : sun@me.utoronto.BITNET
jwz@lucid.com (Jamie Zawinski) (11/12/90)
In article <90Nov10.185352est.20181@me.utoronto.ca> sun@me.utoronto.ca (Andy Sun Anu-guest) wrote: > > I am writing something that needs to know the maximum character height of > a scaled font. Ideally I want to get the maximum height of a string of a > particular font, which is a local maximum depending on the characters (i.e. > aero will have a smaller font height than AERO). Right now I am defining the > scale explictly as a variable so that I can refer to it later but that's > not flexible/intelligent enough to do the job. Any help will be appreciated. To get the bounding box of a string in the current font, you can use gsave newpath 0 0 moveto (Some String) true charpath flattenpath pathbbox grestore But getting the height of the current font is a bit trickier: /currentfont-vextent { % leaves two numbers on the stack: % maximum distances which the current font extends % above the baseline, and below (likely negative). % This fails if the currentfont doesn't have a % FontBBox defined (unlikely). currentfont /FontBBox get dup 0 get exch 1 get currentfont /FontMatrix get dtransform % left bottom exch pop % bottom currentfont /FontBBox get dup 2 get exch 3 get currentfont /FontMatrix get dtransform % bottom right top exch pop % bottom top exch } def