beautypg.com

Scalefont – AMT Datasouth PAL User Manual

Page 172

background image

scalefont

166

The setfont operator creates a reference within the graphics state to the specified
ScaledFontDict. Therefore, so long as the graphics state continues to reference a given
ScaledFontDict, PAL will retain the character images associated with the font.

However, selecting a new font using the setfont operator causes PAL to replace the graphics
state's current font dictionary reference with a reference to the new font dictionary. As a result, the
graphics state no longer references the previous font dictionary. Unless the PAL programmer has
created another reference to the previous font's ScaledFontDict, PAL will automatically discard
the old font dictionary as well as any scaled character images associated with it.

For simple printing applications which require only a single font, managing the character cache
presents little problem. The graphics state's reference to the single ScaledFontDict maintains all
scaled character images.

For more complex printing applications which use multiple fonts, the PAL programmer should
save each ScaledFontDict for as long as the programmer requires the font to ensure that PAL
retains all character images. The following example shows a simple example of how to manage
three fonts under PAL.

1:

/Font1 /

PALFont1

findfont 12.00 scalefont def

2:

/Font2 /

PALFont2

findfont 10.00 scalefont def

3:

/Font3 /

PALFont3

findfont 18.00 scalefont def

4:

72 144 moveto Font1 setfont (Font1 text) show

5:

72 134 moveto Font2 setfont (Font2 text) show

6:

72 116 moveto Font3 setfont (Font3 text) show

The names PALFont1, PALFont2, PALFont3 represent any given font available on a given PAL
printer. Lines one through three locate and establish scaling factors for three arbitrary fonts. Each
line then saves the ScaledFontDict associated with each font under the names Font1, Font2, and
Font3.

Lines four through six use each of these three fonts in turn. When line five performs the sequence
"Font2 setfont", it instructs the interpreter to replace the graphics state reference to Font1 with a
reference to Font2.

At this point, if line one had not saved Font1's ScaledFontDict, PAL would have normally
discarded the ScaledFontDict associated with Font1. This would also result in PAL discarding
any cached characters associated with ScaledFontDict. However, since line one does save
ScaledFontDict, the reference to the ScaledFontDict created causes the interpreter to maintain
the ScaledFontDict in memory. As a result, PAL also maintains the scaled and rotated characters
associated with ScaledFontDict.

PAL maintains only one image for each character associated with a given ScaledFontDict.
Therefore, the programmer should save separate ScaledFontDict dictionaries for every combi-
nation of font, point size, and rotation used.