Name

addText( )

Synopsis

$tb->addText( text   => text,
              font   => font,
              size   => size,
              leading=> leading )

The addText() method adds a new text element to the TextBlock object. A text element can be thought of as a section of text in which all the text has the same characteristics, i.e., where all the characters are the same font, size, and leading. This representation allows you to include text of different fonts and sizes within the same text block by including them as separate elements. Different alignment options have not been included in this version of the TextBlock module, but would be fairly easy to add. All text is left-aligned.

This method takes up to four attributes. If the font, size, or leading attributes are not provided, the default attributes for the TextBlock object are used. The attributes are:

text

The text attribute is required, though nothing bad happens if you leave it out. This is simply the text to be rendered in the text block. Line breaks may be inserted by including a \n newline string.

font

The font attribute is a string indicating the name of the font to be used to render this element. The PostScript package uses an internal description of the font metrics of various fonts, which is contained in the PostScript::Metrics module. The PostScript::Metrics module supports the fonts listed in Table 11-1.

Table 11-1. The fonts encoded in the PostScript::Metrics module

AvantGarde-Book

Helvetica-Narrow-BoldOblique

Palatino-Roman

AvantGarde-BookOblique

Helvetica-Narrow-Oblique

StandardSymL ...

Get Perl Graphics Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.