show Characters

To paint a string of characters, use the show command, which requires a string argument, and expects the font face and size to have been selected:

/Helvetica 10 selectfont
(any string of text characters) show

The show command creates a path of its own. Look what happens when you combine lines with text:

%!PS
0 0 moveto 306 396 lineto
/Helvetica 10 selectfont
(this adds to the path and moves the current point) show
612 792 lineto
stroke
showpage % END OF PROGRAM

show Characters

Advertisements

Comments

Now’s a good time to introduce a little documentation to your programming. Words appearing after a % are comments. (It’s just me, but I like to make them all caps.)

Run the following program in Distiller or Preview to make a PDF file, or in Ghostscript to make an image. You’ll see that all the lines end up running through the exact center of the page:

%!PS
0 396 moveto 612 396 lineto % HORIZ LINE HALFWAY UP THE PAGE
306 0 moveto 306 792 lineto % VERTICAL LINE HALFWAY OVER
0 0 moveto 612 792 lineto % DIAGONAL LINE UP
0 792 moveto 612 0 lineto % DIAGONAL LINE DOWN
stroke % PAINT THE CURRENT PATH
showpage % SEND TO OUTPUT

Lines

We need stroke to paint the current path. It expects nothing on the stack and doesn’t push anything onto the stack. The showpage command doesn’t expect any arguments either. It finally creates the PDF file or image.