[comp.lang.postscript] Simpleton question

dan@maccs.dcss.mcmaster.ca (Dan Trottier) (06/26/91)

I'm trying to write a postscript program to dump character width tables
and print them on the printer. The following code segment works except
I can't seem to print the numeric width:

/prtchar
{   char 0
    3 -1 roll put char dup ==         - puts char to standard out
    dup show                          - puts char to page 
    stringwidth pop 300 mul 72 div    - calculate width
    round cvi dup ==                  - round and put to stdout
    dup cvs show                      - now how do I display width
 } def                                  to page???? Doesn't work!


Any insight to how I would print a number on the top of the stack to 
the graphic page would be very helpfull....

Thanks...	dan
-- 
Dan Trottier                                       dan@maccs.dcss.McMaster.CA
Dept of Computer Science                       ...!uunet!utai!utgpu!maccs!dan
McMaster University                                      (416) 525-9140 x3444

grdetil@ccu.umanitoba.ca (Gilles R. Detillieux) (06/27/91)

In <28678BF9.4393@maccs.dcss.mcmaster.ca> dan@maccs.dcss.mcmaster.ca (Dan Trottier) writes:
>I'm trying to write a postscript program to dump character width tables
>and print them on the printer. The following code segment works except
>I can't seem to print the numeric width:
>/prtchar
>{   char 0
>    3 -1 roll put char dup ==         - puts char to standard out
>    dup show                          - puts char to page 
>    stringwidth pop 300 mul 72 div    - calculate width
>    round cvi dup ==                  - round and put to stdout
>    dup cvs show                      - now how do I display width
> } def                                  to page???? Doesn't work!

The cvs operator must be given a string, which will be overwritten with the
result.  The usage is:  <any> <string> cvs  =>  <substring>
So in your code, you should preallocate a string buffer (outside of the
prtchar procedure):  /str 20 string def
then change the last line in prtchar to:  dup str cvs show
(the dup is needed only if prtchar is supposed to leave the width on the stack).
-- 
Gilles Detillieux			<Gilles@scrc.UManitoba.CA>
Spinal Cord Research Centre		or <grdetil@ccu.UManitoba.CA>
Dept. of Physiology, U. of Manitoba	Phone:  (204)788-6766
Winnipeg, MB  R3E 0W3  (Canada)		Fax:    (204)786-0932

clewis@ferret.ocunix.on.ca (Chris Lewis) (06/27/91)

In article <28678BF9.4393@maccs.dcss.mcmaster.ca> dan@maccs.dcss.mcmaster.ca (Dan Trottier) writes:
>I'm trying to write a postscript program to dump character width tables
>and print them on the printer. The following code segment works except
>I can't seem to print the numeric width:

Incidentally, there are two of these in the psroff distribution.
One of them generates pretty tables with the character at 18 points,
width information along with octal, decimal and hex.  The other generates
a shar with the ditroff width tables for the desired fonts, and spits it
back up the serial line at the computer - all you have to do is unshar
the result and you can use them with ditroff (or psroff of course).  The latter
program comes with tpscript but I've mucked with it a bit to make it more
robust and parameterizable.
-- 
Chris Lewis, Phone: (613) 832-0541, Domain: clewis@ferret.ocunix.on.ca
UUCP: ...!cunews!latour!ecicrl!clewis; Ferret Mailing List:
ferret-request@eci386; Psroff (not Adobe Transcript) enquiries:
psroff-request@eci386 or Canada 416-832-0541.  Psroff 3.0 in c.s.u soon!