opensubscriber
   Find in this group all groups
 
Unknown more information…

g : gs-devel@ghostscript.com 19 December 2009 • 5:02AM -0500

Re: [gs-devel] PostScript Question
by James Cloos

REPLY TO AUTHOR
 
REPLY TO GROUP




>>>>> "Levi" == Levi  <skankwilsonite@gmai...> writes:

Levi> How can you calculate the height of a line of text based upon the
Levi> current font?

Levi> I've seen the following postscript that purports to do this, but
Levi> it didn't seem to work for me:

Levi> /fontheight { currentfont /FontMatrix get 3 get } bind def

A quick test tells all.

:; gs -dNODISPLAY
GPL Ghostscript 8.70 (2009-07-31)
Copyright (C) 2009 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>/Helvetica  findfont 11 scalefont setfont                
Loading NimbusSanL-Regu font from /usr/share/ghostscript/8.70/Resource/Font/NimbusSanL-Regu... 2607872 1070413 6352632 5068722 1 done.
GS>currentfont
GS<1>/FontMatrix get
GS<1>3 get
GS<1>stack
0.011
GS<1>

As you can see, the result of {currentfont /FontMatrix get 3 get}, which
returns the 3rd element of the array which is the /FontMatrix element of
the dictionary returned by the currentfont command, is in glyph units.

The /FontMatrix started at as:

/FontMatrix [0.001 0 0 0.001 0 0 ]readonly def

and got multiplied by 11 when you ran {11 scalefont}.  Trying to use that
is not all that dissimilar than just using 11 (presuming that you know
that you have run or will run {11 scalefont}).

-JimC
--
James Cloos <cloos@jhcl...>         OpenPGP: 1024D/ED7DAEA6
_______________________________________________
gs-devel mailing list
gs-devel@ghos...
http://ghostscript.com/cgi-bin/mailman/listinfo/gs-devel

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.