Article View: comp.lang.postscript
Article #5896Re: How to make fixed width fonts with non-fixed width fonts
From: Henry Churchyard
Date: Sun, 13 Dec 1992 04:43
Date: Sun, 13 Dec 1992 04:43
35 lines
1866 bytes
1866 bytes
In article <1992Dec8.203206.17023@frmug.fr.mugnet.org>, serguei@frmug.fr.mugnet.org (Serge Weinstock) writes:
>
> Does anyone know how to make a fixed width font with a
> non-fixed width font ?
Yes, but the result will not generally be pretty. Here's a
procedure from Peter da Silva that will horizontally compress (scale)
a character which is wider than a requested fixed-width box, and will
horizontally center narrower characters within the box:
/cwshow % string width -- From Peter da Silva, thanks!
{ 4 dict begin
/width exch def
/buffer ( ) def
{ buffer exch 0 exch put
width buffer stringwidth pop sub 2 div
dup -0.05 lt { pop gsave
currentpoint translate
width buffer stringwidth pop div 0.95 mul 1 scale
buffer show
grestore width 0 rmoveto }
{ dup 0 rmoveto buffer show 0 rmoveto }
ifelse } forall end } def
I would use this procedure by defining a procedure _myshow_ which
will be used in place of _show_ for the fonts we are monospacifying.
If you keep track of the current pointsize in a variable _ptsize_,
then a good definition of _myshow_ is:
/myshow {ptsize .6 mul cwshow} def
Here using .6 guarantees width compatibility with Courier fonts of
the same pointsize; feel free to experiment with different values...
--
--Henry Churchyard churchh@emx.cc.utexas.edu
Technical Details
Message-ID:
<85227@ut-emx.uucp>Path:
arc1-ca.pugleaf.net!sparky!uunet!wupost!cs.utexas.edu!ut-emx!churchhReferences:
<1992Dec8.203206.17023@frmug.fr.mugnet.org>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!cs.utexas.edu!ut-emx!churchh From: churchh@ut-emx.uucp (Henry Churchyard) Newsgroups: comp.lang.postscript Subject: Re: How to make fixed width fonts with non-fixed width fonts Summary: cwshow procedure -- Peter da Silva Keywords: postscript Message-ID: <85227@ut-emx.uucp> Date: 13 Dec 92 04:43:20 GMT References: <1992Dec8.203206.17023@frmug.fr.mugnet.org> Organization: The University of Texas at Austin, Austin, Texas Lines: 36