Article View: comp.lang.postscript
Article #6978Re: Anything but Courier!!
From: Geoffrey Cooper
Date: Sat, 12 Mar 1988 01:59
Date: Sat, 12 Mar 1988 01:59
48 lines
1940 bytes
1940 bytes
To make a font monospaced, just add a Metrics directory into any font
with all the characters having the same width. Take the width of a
particular character (an M will guarantee that characters don't
overlap) and use CharStrings to ensure that all characters are
given the new metric. The code included below does this.
The output is pretty dreadful, because no attempt is made to center the
characters within the em space. To do that, you'd have to go to the
next level of metrics dictionary, where each entry is a pair,
containing left side bearing and metrics info. To center each
character, you need to know its bounding box. You can either work on a
host from an AFM file, or compute the bounding boxes by taking the
charpath of the character and flattening it. The latter approach is
computationally expensive, but the resultant font will still print well.
Don't expect the results to be too good, since the fonts are not
designed to look good when spaced that way.
------monospace.ps-------
%!
/make_monospace
{
findfont dup setfont (M) stringwidth pop 1000 mul /_w exch def
dup length 1 add dict begin
{
1 index /FID eq { pop pop } { def } ifelse
}
forall
currentdict end
dup
dup /CharStrings get dup length dict begin
{
pop _w def
}
forall
/Metrics currentdict put end
definefont
}
def
/Times-Mono /Times-Roman make_monospace 10 scalefont setfont
72 72 moveto
(This is some text in Times monospace.) show
showpage
------------------
--
{decwrl,sun,saber}!imagen!geof
Technical Details
Message-ID:
<1662@imagen.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!portal!atari!imagen!geofReferences:
<20453@bu-cs.BU.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!portal!atari!imagen!geof From: geof@imagen.UUCP (Geoffrey Cooper) Newsgroups: comp.lang.postscript Subject: Re: Anything but Courier!! Message-ID: <1662@imagen.UUCP> Date: 12 Mar 88 01:59:35 GMT References: <20453@bu-cs.BU.EDU> Organization: IMAGEN Corporation, Santa Clara, CA 95052-8101 Lines: 48