Fixed the pod path in archive
[sdlgit/SDL_perl.git] / lib / pods / SDL / TTFont.pod
CommitLineData
896b04ee 1=head1 NAME
2
3SDL::TTFont - a SDL perl extension
4
5=head1 SYNOPSIS
6
7 $font = SDL::TTFont->new( -name => "Utopia.ttf", -size => 18 );
8
9=head1 DESCRIPTION
10
11L<< SDL::TTFont >> is a module for applying true type fonts to L<< SDL::Surface >>.
12
13=head1 METHODS
14
15=head2 new
16
17Instanciates a new font surface. It accepts the following parameters:
18
19=head3 -name
20
21=head3 -n
22
23The font filename (possibly with proper path) to be used. B<< This options is mandatory >>.
24
25=head3 -size
26
27=head3 -s
28
29The font size (height, in pixels) to be used. B<< This option is mandatory >>.
30
31=head3 -foreground
32
33=head3 -fg
34
35Foreground color for the font surface (i.e. the actual font color). It expects a
36SDL::Color value. If omitted, black is used as font color.
37
38=head3 -background
39
40=head3 -bg
41
42Background color for the font surface (i.e. the font background color). It expects
43a SDL::Color value. If omitted , white is used for the background.
44
45=head3 -mode
46
47=head3 -m
48
49Font mode. If omitted, SDL::TEXT_SHADED is used. Note that this class provides
50human friendly accessors for setting different modes, so you should probably use
51them instead. See below for further details.
52
53=head2 Text Modes
54
55The SDL::TTFont accepts three different types (shaded, solid, blended) for
56three different encodings (text, utf8, unicode).
57
58 $font->text_shaded; # sets mode to SDL::TEXT_SHADED
59 $font->text_solid; # sets mode to SDL::TEXT_SOLID
60 $font->text_blended; # sets mode to SDL::TEXT_BLENDED
61
62 $font->utf8_shaded; # sets mode to SDL::UTF8_SHADED
63 $font->utf8_solid; # sets mode to SDL::UTF8_SOLID
64 $font->utf8_blended; # sets mode to SDL::UTF8_BLENDED
65
66 $font->unicode_shaded; # sets mode to SDL::UNICODE_SHADED
67 $font->unicode_solid; # sets mode to SDL::UNICODE_SOLID
68 $font->unicode_blended; # sets mode to SDL::UNICODE_BLENDED
69
70=head2 Text Style
71
72You may also smoothly change your font style by calling any of the following
73methods:
74
75 $font->normal; # resets font styling, making text "normal"
76 $font->bold; # sets bold style for font
77 $font->italic; # sets italic style for font
78 $font->underline; # sets underline style for font
79
80
81=head2 Ascent/Descent values
82
83Ascent is the number of pixels from the font baseline to the top of the font, while
84descent is the number of pixels from the font baseline to the bottom of the font.
85
86 $font->ascent; # height in pixels of the font ascent
87 $font->descent; # height in pixels of the font descent
88
89=head2 height
90
91 my $height = $font->height;
92
93Returns the height, in pixels, of the actual rendered text. This is the
94average size for each glyph in the font.
95
96=head2 width(@text)
97
98 my $width = $font->width("Choose your destiny");
99
100Returns the dimensions needed to render the text. This can be used to help
101determine the positioning needed for text before it is rendered. It can also
102be used for wordwrapping and other layout effects.
103
104Be aware that most fonts - notably, non-monospaced ("ms") ones - use kerning
105which adjusts the widths for specific letter pairs. For example, the width
106for "ae" will not always match the width for "a" + "e".
107
108=head2 print ($surface, $top, $left, @text)
109
110Directly draws text to an existing surface. Receives the target L<< SDL::Surface >>
111object and the relative top (y) and left (x) coordinates to put the text in.
112The last parameter may be a string or an array or strings with the text to be
113written.
114
115
116=head1 AUTHOR
117
118David J. Goehrig
119
120=head1 SEE ALSO
121
122L<perl>, L<SDL>, L<< SDL::Surface >>