Fonts in PostScript are actually
A font dictionary contains several operators. Most of these operators
simply set up the path for a single character in the font. When
PostScript needs to typeset an 'A' in the current font, it finds the
operator specified in the font for 'A' and invokes it. This operator
goes about the business of drawing the letter. This means that there
is no fundamental difference between letters and any other kind of ink
on the page: text is graphics. Furthermore, since a font is
essentially just a program to draw things, the current graphics state
applies to text just as much as it applies to lines and curves which
your program draws. This is one of the most powerful features of
PostScript, as we will see later.
The fonts themselves are stored in a special dictionary of fonts, and they are named. If you want to retrieve a font by name, you need to use the findfont operator. findfont retrieves the font from the dictionary (if it is there) and leaves the font on the stack. You can then specify how big the font should be and make it the current font. The basic process for setting the font is:
For example, let us say that we want to start typesetting in Times Roman, and we want it to be set to 20 points. The following code would set up the correct font:
/Times-Roman findfont % Get the basic font 20 scalefont % Scale the font to 20 points setfont % Make it the current fontSince the font "Times-Roman" is stored in a dictionary, we search for it using its PostScript name. Your printer will usually come with a set of built in fonts and will almost always allow you to add more. The names of the fonts available will vary from printer to printer, but Times is almost always present. Fonts typically come in families. "Times" is the name of the family we used here, and it has four member fonts: Times-Roman, Times-Italic, Time-Bold, and Times-BoldItalic.
The show operator is used to
typeset text on the page. It takes a single argument: a string
containing the text to be typeset. Text can be considered to be part
of the path, so you must also have set the current point with call to
moveto or an equivalent operator. A typical call to show might look
newpath % Start a new path 72 72 moveto % Lower left corner of text at (72, 72) (Hello, world!) show % Typeset "Hello, world!"If we ran this code right after the font selection code above, we would get the string "Hello, world!" printed an inch in from the lower left corner, and it would be printed in 20 point Times-Roman. You can actually try this example.