[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] estimating printed width of some text



I have worked with Postscript and found the following:

Most fonts are porportional.  That is to say that if a font is 9pt then
it's typical width is 5-7.  You can check this out with MacPerl via the
Quickdraw routines which allow you to check a pixel to see if it is some
color.  Just make a rectangle which is more than large enough to hold a
given character (ie: use a 30x30 box for the 9pt font).  Then print the
character inside of the box and scan across to see how large the
character is.

Anyway, if you know that a 9pt font is no large than 7 dots across then
you have a rough estimate of just how wide any given line will be.  But
there is one more step to this.  Certain letters are wider than others. 
Specifically, "m" and "M" are about the widest characters with "w" and
"W" being up there with them.  So if for each time you see an "m" or a
"w" you add half again as much (ie: for 5 you add 3 and for 7 you add 4)
on to the number of dots across a string will take you are assured of
almost always getting the width the right size.  At least - it works for
me.  I've written a lot of Postscript reports and wanted to wrap the
text at a given column.  By using the above I've never had text go out
side of the box.  Although I have had it go right up agains the box.

I hope this helps.  :-)

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch