3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
7 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
8 <li><a href="#METHODS">METHODS</a>
9 <ul><li><a href="#new">new</a>
10 <ul><li><a href="#name">-name</a></li>
11 <li><a href="#n">-n</a></li>
12 <li><a href="#size">-size</a></li>
13 <li><a href="#s">-s</a></li>
14 <li><a href="#foreground">-foreground</a></li>
15 <li><a href="#fg">-fg</a></li>
16 <li><a href="#background">-background</a></li>
17 <li><a href="#bg">-bg</a></li>
18 <li><a href="#mode">-mode</a></li>
19 <li><a href="#m">-m</a></li>
22 <li><a href="#Text_Modes">Text Modes</a></li>
23 <li><a href="#Text_Style">Text Style</a></li>
24 <li><a href="#Ascent_Descent_values">Ascent/Descent values</a></li>
25 <li><a href="#height">height</a></li>
26 <li><a href="#width_text">width(@text)</a></li>
27 <li><a href="#print_surface_top_left_text">print ($surface, $top, $left, @text)</a></li>
30 <li><a href="#AUTHOR">AUTHOR</a></li>
31 <li><a href="#SEE_ALSO">SEE ALSO</a>
36 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
37 <div id="NAME_CONTENT">
38 <p>SDL::TTFont - a SDL perl extension</p>
41 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
42 <div id="SYNOPSIS_CONTENT">
43 <pre> $font = SDL::TTFont->new( -name => "Utopia.ttf", -size => 18 );
48 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
49 <div id="DESCRIPTION_CONTENT">
50 <p><cite>SDL::TTFont</cite> is a module for applying true type fonts to <cite>SDL::Surface</cite>.</p>
53 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
54 <div id="METHODS_CONTENT">
58 <div id="new_CONTENT">
59 <p>Instanciates a new font surface. It accepts the following parameters:</p>
62 <h3 id="name">-name</h3>
63 <div id="name_CONTENT">
68 <p>The font filename (possibly with proper path) to be used. <strong>This options is mandatory</strong>.</p>
71 <h3 id="size">-size</h3>
72 <div id="size_CONTENT">
77 <p>The font size (height, in pixels) to be used. <strong>This option is mandatory</strong>.</p>
80 <h3 id="foreground">-foreground</h3>
81 <div id="foreground_CONTENT">
86 <p>Foreground color for the font surface (i.e. the actual font color). It expects a
87 SDL::Color value. If omitted, black is used as font color.</p>
90 <h3 id="background">-background</h3>
91 <div id="background_CONTENT">
96 <p>Background color for the font surface (i.e. the font background color). It expects
97 a SDL::Color value. If omitted , white is used for the background.</p>
100 <h3 id="mode">-mode</h3>
101 <div id="mode_CONTENT">
106 <p>Font mode. If omitted, SDL::TEXT_SHADED is used. Note that this class provides
107 human friendly accessors for setting different modes, so you should probably use
108 them instead. See below for further details.</p>
111 <h2 id="Text_Modes">Text Modes</h2>
112 <div id="Text_Modes_CONTENT">
113 <p>The SDL::TTFont accepts three different types (shaded, solid, blended) for
114 three different encodings (text, utf8, unicode).</p>
115 <pre> $font->text_shaded; # sets mode to SDL::TEXT_SHADED
116 $font->text_solid; # sets mode to SDL::TEXT_SOLID
117 $font->text_blended; # sets mode to SDL::TEXT_BLENDED
119 $font->utf8_shaded; # sets mode to SDL::UTF8_SHADED
120 $font->utf8_solid; # sets mode to SDL::UTF8_SOLID
121 $font->utf8_blended; # sets mode to SDL::UTF8_BLENDED
123 $font->unicode_shaded; # sets mode to SDL::UNICODE_SHADED
124 $font->unicode_solid; # sets mode to SDL::UNICODE_SOLID
125 $font->unicode_blended; # sets mode to SDL::UNICODE_BLENDED
130 <h2 id="Text_Style">Text Style</h2>
131 <div id="Text_Style_CONTENT">
132 <p>You may also smoothly change your font style by calling any of the following
134 <pre> $font->normal; # resets font styling, making text "normal"
135 $font->bold; # sets bold style for font
136 $font->italic; # sets italic style for font
137 $font->underline; # sets underline style for font
145 <h2 id="Ascent_Descent_values">Ascent/Descent values</h2>
146 <div id="Ascent_Descent_values_CONTENT">
147 <p>Ascent is the number of pixels from the font baseline to the top of the font, while
148 descent is the number of pixels from the font baseline to the bottom of the font.</p>
149 <pre> $font->ascent; # height in pixels of the font ascent
150 $font->descent; # height in pixels of the font descent
155 <h2 id="height">height</h2>
156 <div id="height_CONTENT">
157 <pre> my $height = $font->height;
160 <p>Returns the height, in pixels, of the actual rendered text. This is the
161 average size for each glyph in the font.</p>
164 <h2 id="width_text">width(@text)</h2>
165 <div id="width_text_CONTENT">
166 <pre> my $width = $font->width("Choose your destiny");
169 <p>Returns the dimensions needed to render the text. This can be used to help
170 determine the positioning needed for text before it is rendered. It can also
171 be used for wordwrapping and other layout effects.</p>
172 <p>Be aware that most fonts - notably, non-monospaced ("ms") ones - use kerning
173 which adjusts the widths for specific letter pairs. For example, the width
174 for "ae" will not always match the width for "a" + "e".</p>
177 <h2 id="print_surface_top_left_text">print ($surface, $top, $left, @text)</h2>
178 <div id="print_surface_top_left_text_CONTENT">
179 <p>Directly draws text to an existing surface. Receives the target <cite>SDL::Surface</cite>
180 object and the relative top (y) and left (x) coordinates to put the text in.
181 The last parameter may be a string or an array or strings with the text to be
189 <h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
190 <div id="AUTHOR_CONTENT">
191 <p>David J. Goehrig</p>
194 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
195 <div id="SEE_ALSO_CONTENT">
196 <p><cite>perl</cite>, <cite>SDL</cite>, <cite>SDL::Surface</cite>