addText( ) — add a new element to a text block


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

The addText( ) method will add a new text element to the TextBlock object. A “text element” can be thought of as a section of text that has the same characteristics (i.e., all the characters are the same font, size, and leading). This representation allows you to include text rendered in multiple fonts at multiple 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:


The text attribute is required, though nothing bad will happen 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.


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 following fonts, which corresponds with the set of default Ghostscript fonts with have AFM files:



CenturySchL-Ital ...

Get Programming Web Graphics with Perl and GNU Softwar now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.