🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #3650

Re: Variable characters

#3650
From: Kenneth Porter
Date: Tue, 13 Nov 1990 06:01
34 lines
1787 bytes

toms@fcs260c2.ncifcrf.gov (Tom Schneider) provided some code
demonstrating that scaling up a font bbox doesn't work.  After
some experimentation with Tom's sample code, I found that fonts
don't scale uniformly.  It is necessary to calculate the bbox
at the desired size, which leads to a chicken-and-egg problem.
 
Try setting the fontsize parameter in his code to first, 1
point, then 825 points.  In the first case, the characters
don't fit their expected bbox at all.  In the second case, they
fit quite well.  The number 825 is a compromise among the
ymulfactors of the final characters.
 
My error in assuming simple scaling would work partly stems
from my ignorance that Tom needed this much accuracy.  In my
own applications I could tolerate a fair amount of slop and I
was using small point sizes.
 
Apparently, to get a good fit, it is necessary to iterate the
bbox-calculating procedure a couple of times, using the result
from each iteration to compute the font scale factor for
scalefont for the next iteration.  A couple of iterations
should get you pretty close to a good fit.
 
In pseudo-code:
 
fontscale = 1
do {
  calculate character bbox
  fontscale = fontscale * desired_bbox / calculated_bbox
} while abs(desired_bbox-calculated_bbox) > acceptable_error
 
Ken (shiva@well.sf.ca.us)
Technical Details
Message-ID: <21630@well.sf.ca.us>
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!apple!well!shiva
References: <1902@fcs280s.ncifcrf.gov> <21131@well.sf.ca.us> <1936@fcs280s.ncifcrf.gov>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!apple!well!shiva
From: shiva@well.sf.ca.us (Kenneth Porter)
Newsgroups: comp.lang.postscript
Subject: Re: Variable characters
Summary: Iterative solution
Keywords: font, character size
Message-ID: <21630@well.sf.ca.us>
Date: 13 Nov 90 06:01:33 GMT
References: <1902@fcs280s.ncifcrf.gov> <21131@well.sf.ca.us> <1936@fcs280s.ncifcrf.gov>
Lines: 34