Article View: comp.lang.postscript
Article #3303Re: Variable characters
From: This space for rent
Date: Tue, 09 Oct 1990 17:48
Date: Tue, 09 Oct 1990 17:48
80 lines
4149 bytes
4149 bytes
In article <1902@fcs280s.ncifcrf.gov> toms@fcs260c2.ncifcrf.gov (Tom
Schneider) writes:
> I would like to make some characters of a precise size, for example,
> 10.3 cm high. I am being thwarted because fonts are not consistent
> between PostScript printers. That is, if I draw a character to fit just
> outside a rectangle and show it on NeWS, then the same program makes the
> character INSIDE the rectangle when printed to a LaserWriter ntxII.
>
> This Is Frustrating! :-(
>
> Is there any way to rescale the font so that it is the same size on all
> printers? For example, is there an easy way to get a hold of the exact
> character size so as to correct for these non-standard effects? (And I
> thought PostScript was supposed to be a standard language, hruummph!
> Aren't there people working on making this more standard?)
>
The problem facing you is that, while the PostScript language is more or
less standard, the font shapes depend on the designer, type vendor, or
language implementation. The fonts used in NeWS are not exactly the same
as those from Adobe, which are not the same as those from Bitstream, which
are not the same as the original lead type, etc. (This is an
industry-wide issue.) One way to compensate for this in PostScript is to
use the charpath and pathbbox operators and scale appropriately.
This routine takes a fontname, a string, and a height in points, and
scales the font so that every character in the string prints at the same
height. It also adjusts the currentpoint so that every character rests on
the baseline (try it with "g"!). The results are pretty hideous for
anything except what you are trying to do:
/heightshow { % fontname string height heightshow -
/ht exch def
/str exch def
/fnt exch def
/s1 1 string def
str { % for each char in the string
s1 0 3 -1 roll put % convert char to string
gsave
newpath
0 0 moveto
fnt findfont setfont
s1 true charpath
flattenpath
pathbbox % compute bounding box of 1 pt. char
2 index sub % ury - lly = char height
ht exch div % scale for char to match req. height
/scalefactor exch def
pop % don't need urx
scalefactor mul % adjust lly so char sits on baseline
/yadjust exch def
pop % don't need llx
grestore
fnt findfont scalefactor scalefont setfont
0 yadjust neg rmoveto
s1 show
0 yadjust rmoveto
} forall
} bind def
/ptspercm 72.0 2.54 div def
36 36 moveto
/Helvetica-Bold (C) 10.3 ptspercm mul heightshow
showpage
> If I could build a font from scratch, then it would solve another problem
> I have, which is that in the font I prefer (Helvetica-Bold), some of the
> characters reach above and below the line they rest on. That is, relative
> to an A, the letters C and G extend above and below the lines. This is a
> royal pain for what I'm doing. So far, I have had to empirically figure
> out scale factors to correct for this. It would be nice to have a clean
> solution, like a font which I have complete control over.
>
Having rounded characters extend above and below the lines may be a royal
pain for what you are doing, but it is essential for legible typography.
(To see this, print something like "CHEOPS" with the heightshow routine...
the rounded characters will appear smaller than the non-rounded
characters!)
--Kevin Andresen [kevina@apple.com]
"Technically, Sen. Helms is a member of the arachnid family."
Technical Details
Message-ID:
<10628@goofy.Apple.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!bu.edu!snorkelwacker!apple!apple.com!kevinaReferences:
<1902@fcs280s.ncifcrf.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!bu.edu!snorkelwacker!apple!apple.com!kevina From: kevina@apple.com (This space for rent) Newsgroups: comp.lang.postscript Subject: Re: Variable characters Message-ID: <10628@goofy.Apple.COM> Date: 9 Oct 90 17:48:42 GMT References: <1902@fcs280s.ncifcrf.gov> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 80