Strings and Fonts

When you load the GD module the five built-in fonts are imported into your script’s namespace as the global variables gdGiantFont, gdLargeFont, gdMediumBoldFont, gdSmallFont, and gdTinyFont (see Figure 2-7). They are all fixed-width fonts with 256 characters in their character sets. The dimensions of each can be determined with the width( ) and height( ) object methods, or by consulting Table 2-1.

Table 2-1. The dimensions of the five standard GD fonts

Font name

Width (pixels)

Height (pixels)

gdTinyFont

5

8

gdSmallFont

6

12

gdMediumBoldFont

7

12

gdLargeFont

8

16

gdGiantFont

9

15

The built-in bitmapped GD fonts.
Figure 2-7. The built-in bitmapped GD fonts.

To draw a string with the bitmapped fonts, use the char( ), charUp( ), string( ), or stringUp( ) methods. To use a TrueType font, use the stringFT( ) method.

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.