Commit | Line | Data |
162a0989 |
1 | <div class="pod"> |
2 | <!-- INDEX START --> |
3 | <h3 id="TOP">Index</h3> |
4 | |
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> |
20 | </ul> |
21 | </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> |
28 | </ul> |
29 | </li> |
30 | <li><a href="#AUTHOR">AUTHOR</a></li> |
31 | <li><a href="#SEE_ALSO">SEE ALSO</a> |
32 | </li> |
33 | </ul><hr /> |
34 | <!-- INDEX END --> |
35 | |
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> |
39 | |
40 | </div> |
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 ); |
44 | |
45 | </pre> |
46 | |
47 | </div> |
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> |
51 | |
52 | </div> |
53 | <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
54 | <div id="METHODS_CONTENT"> |
55 | |
56 | </div> |
57 | <h2 id="new">new</h2> |
58 | <div id="new_CONTENT"> |
59 | <p>Instanciates a new font surface. It accepts the following parameters:</p> |
60 | |
61 | </div> |
62 | <h3 id="name">-name</h3> |
63 | <div id="name_CONTENT"> |
64 | |
65 | </div> |
66 | <h3 id="n">-n</h3> |
67 | <div id="n_CONTENT"> |
68 | <p>The font filename (possibly with proper path) to be used. <strong>This options is mandatory</strong>.</p> |
69 | |
70 | </div> |
71 | <h3 id="size">-size</h3> |
72 | <div id="size_CONTENT"> |
73 | |
74 | </div> |
75 | <h3 id="s">-s</h3> |
76 | <div id="s_CONTENT"> |
77 | <p>The font size (height, in pixels) to be used. <strong>This option is mandatory</strong>.</p> |
78 | |
79 | </div> |
80 | <h3 id="foreground">-foreground</h3> |
81 | <div id="foreground_CONTENT"> |
82 | |
83 | </div> |
84 | <h3 id="fg">-fg</h3> |
85 | <div id="fg_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> |
88 | |
89 | </div> |
90 | <h3 id="background">-background</h3> |
91 | <div id="background_CONTENT"> |
92 | |
93 | </div> |
94 | <h3 id="bg">-bg</h3> |
95 | <div id="bg_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> |
98 | |
99 | </div> |
100 | <h3 id="mode">-mode</h3> |
101 | <div id="mode_CONTENT"> |
102 | |
103 | </div> |
104 | <h3 id="m">-m</h3> |
105 | <div id="m_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> |
109 | |
110 | </div> |
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 |
118 | |
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 |
122 | |
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 |
126 | |
127 | </pre> |
128 | |
129 | </div> |
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 |
133 | methods:</p> |
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 |
138 | |
139 | |
140 | |
141 | |
142 | </pre> |
143 | |
144 | </div> |
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 |
151 | |
152 | </pre> |
153 | |
154 | </div> |
155 | <h2 id="height">height</h2> |
156 | <div id="height_CONTENT"> |
157 | <pre> my $height = $font->height; |
158 | |
159 | </pre> |
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> |
162 | |
163 | </div> |
164 | <h2 id="width_text">width(@text)</h2> |
165 | <div id="width_text_CONTENT"> |
166 | <pre> my $width = $font->width("Choose your destiny"); |
167 | |
168 | </pre> |
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> |
175 | |
176 | </div> |
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 |
182 | written.</p> |
183 | |
184 | |
185 | |
186 | |
187 | |
188 | </div> |
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> |
192 | |
193 | </div> |
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> |
197 | </p> |
198 | |
199 | </div> |
200 | </div> |