update constants
[sdlgit/SDL-Site.git] / pages / SDL-Pango.html-inc
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="#CATEGORY">CATEGORY</a></li>
7 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
8 <li><a href="#CONSTANTS">CONSTANTS</a></li>
9 <li><a href="#METHODS">METHODS</a>
10 <ul><li><a href="#init">init</a></li>
11 <li><a href="#was_init">was_init</a></li>
12 <li><a href="#set_default_color">set_default_color</a></li>
13 <li><a href="#set_minimum_size">set_minimum_size</a></li>
14 <li><a href="#set_text">set_text</a></li>
15 <li><a href="#set_markup">set_markup</a></li>
16 <li><a href="#get_layout_width">get_layout_width</a></li>
17 <li><a href="#get_layout_height">get_layout_height</a></li>
18 <li><a href="#set_base_direction">set_base_direction</a></li>
19 <li><a href="#set_dpi">set_dpi</a></li>
20 <li><a href="#set_language">set_language</a></li>
21 <li><a href="#draw">draw</a></li>
22 <li><a href="#set_surface_create_args">set_surface_create_args</a></li>
23 <li><a href="#create_surface_draw">create_surface_draw</a></li>
24 </ul>
25 </li>
26 <li><a href="#AUTHOR">AUTHOR</a></li>
27 <li><a href="#SEE_ALSO">SEE ALSO</a>
28 </li>
29 </ul><hr />
30 <!-- INDEX END -->
31
32 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
33 <div id="NAME_CONTENT">
34 <p>SDL::Pango - Text rendering engine</p>
35
36 </div>
37 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
38 <div id="CATEGORY_CONTENT">
39 <p>Pango</p>
40
41 </div>
42 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
43 <div id="SYNOPSIS_CONTENT">
44 <pre> use SDL;
45  use SDL::Color;
46  use SDL::Surface;
47  use SDL::Overlay;
48  use SDL::Rect;
49  use SDL::Video;
50  use SDL::PixelFormat;
51  use SDL::Pango;
52  use SDL::Pango::Context;
53
54  SDL::Pango::init();
55
56  my $context = new SDL::Pango::Context;
57  SDL::Pango::set_default_color($context, 0xA7C344FF, 0);
58  SDL::Pango::set_markup($context, 'Hallo &lt;b&gt;W&lt;span foreground=&quot;red&quot;&gt;o&lt;/span&gt;&lt;i&gt;r&lt;/i&gt;&lt;u&gt;l&lt;/u&gt;d&lt;/b&gt;!', -1);
59
60  SDL::init(SDL_INIT_VIDEO);
61
62  my $display = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE);
63  my $bg      = SDL::Video::map_RGB($display-&gt;format, 0x12, 0x22, 0x45);
64  SDL::Video::fill_rect($display, SDL::Rect-&gt;new(0, 0, 640, 480), $bg);
65
66  my $surface = SDL::Pango::create_surface_draw($context);
67  SDL::Video::blit_surface($surface, SDL::Rect-&gt;new(0, 0, 640, 480), $display, SDL::Rect-&gt;new(0, 0, 640, 480));
68
69  SDL::Video::update_rect($display, 0, 0, 0, 0);
70  SDL::delay(2000);
71
72 </pre>
73
74 </div>
75 <h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
76 <div id="CONSTANTS_CONTENT">
77 <p>The constants are not exported by default. You can export them into your namespace by doing:</p>
78 <pre> use SDL::Pango ':direction';
79
80 </pre>
81 <p>or</p>
82 <pre> use SDL::Pango ':all';
83
84 </pre>
85 <p>or access them directly:</p>
86 <pre> SDL::Pango::SDLPANGO_DIRECTION_NEUTRAL;
87
88 </pre>
89 <p>Available constants:</p>
90 <dl>
91         <dt>SDLPANGO_DIRECTION_LTR</dt>
92         <dd>
93                 <p>Left to right</p>
94         </dd>
95         <dt>SDLPANGO_DIRECTION_RTL</dt>
96         <dd>
97                 <p>Right to left</p>
98         </dd>
99         <dt>SDLPANGO_DIRECTION_WEAK_LTR</dt>
100         <dd>
101                 <p>Left to right (weak)</p>
102         </dd>
103         <dt>SDLPANGO_DIRECTION_WEAK_RTL</dt>
104         <dd>
105                 <p>Right to left (weak)</p>
106         </dd>
107         <dt>SDLPANGO_DIRECTION_NEUTRAL</dt>
108         <dd>
109                 <p>Neutral</p>
110         </dd>
111 </dl>
112
113 </div>
114 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
115 <div id="METHODS_CONTENT">
116
117 </div>
118 <h2 id="init">init</h2>
119 <div id="init_CONTENT">
120 <pre> SDL::Pango::init();
121
122 </pre>
123 <p>Initialize the Glib and Pango API. This must be called before using other functions in this library, excepting <a href="/SDL-Pango.html#was_init">SDL::Pango::was_init</a>. 
124 SDL does not have to be initialized before this call.</p>
125 <p>Returns: always <code>0</code>. </p>
126
127 </div>
128 <h2 id="was_init">was_init</h2>
129 <div id="was_init_CONTENT">
130 <pre> my $was_init = SDL::Pango::was_init();
131
132 </pre>
133 <p>Query the initilization status of the Glib and Pango API. You may, of course, use this before <a href="/SDL-Pango.html#init">SDL::Pango::init</a> to avoid initilizing twice 
134 in a row.</p>
135 <p>Returns: Non-zero when already initialized. Zero when not initialized.</p>
136
137 </div>
138 <h2 id="set_default_color">set_default_color</h2>
139 <div id="set_default_color_CONTENT">
140 <pre> SDL::Pango::set_default_color($context, $foreground, $background);
141  SDL::Pango::set_default_color($context, $r1, $g1, $b1, $a1, $r2, $g2, $b2, $a2);
142
143 </pre>
144 <p>Sets default foreground and background color when rendering text and markup.</p>
145 <p>You can call it with either 2 color-parameters (32-bit RRGGBBAA values), or with 4 separate values for foreground and 4 separate values for 
146 background.</p>
147
148 </div>
149 <h2 id="set_minimum_size">set_minimum_size</h2>
150 <div id="set_minimum_size_CONTENT">
151 <pre> SDL::Pango::set_minimum_size($context, $width, $height);
152
153 </pre>
154 <p>Sets the minimum size of the drawing rectangle.</p>
155
156 </div>
157 <h2 id="set_text">set_text</h2>
158 <div id="set_text_CONTENT">
159 <pre> SDL::Pango::set_text($context, $text, $length);
160
161 </pre>
162 <p>Set plain text to context. Text must be utf-8. <code>$length</code> chars will be rendered, pass <code>-1</code> to render the whole text.</p>
163
164 </div>
165 <h2 id="set_markup">set_markup</h2>
166 <div id="set_markup_CONTENT">
167 <pre> SDL::Pango::set_markup($context, $text, $length);
168
169 </pre>
170 <p>Set markup text to context. Text must be utf-8. <code>$length</code> chars will be rendered, pass <code>-1</code> to render the whole text.</p>
171 <p>See <a href="http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html">PangoMarkupFormat</a> for a description about the markup format.</p>
172
173 </div>
174 <h2 id="get_layout_width">get_layout_width</h2>
175 <div id="get_layout_width_CONTENT">
176 <pre> my $w = SDL::Pango::get_layout_width($context);
177
178 </pre>
179 <p>Returns the width of the resulting surface of the given text/markup for this context.</p>
180
181 </div>
182 <h2 id="get_layout_height">get_layout_height</h2>
183 <div id="get_layout_height_CONTENT">
184 <pre> my $h = SDL::Pango::get_layout_height($context);
185
186 </pre>
187 <p>Returns the height of the resulting surface of the given text/markup for this context.</p>
188
189 </div>
190 <h2 id="set_base_direction">set_base_direction</h2>
191 <div id="set_base_direction_CONTENT">
192 <pre> SDL::Pango::set_base_direction($context, $direction);
193
194 </pre>
195 <p>Sets the direction of the text to either left-to-right or right-to-left.</p>
196 <p>See <a href="#CONSTANTS">CONSTANTS</a>.</p>
197
198 </div>
199 <h2 id="set_dpi">set_dpi</h2>
200 <div id="set_dpi_CONTENT">
201 <pre> SDL::Pango::set_dpi($context, $dpi_x, $dpi_y);
202
203 </pre>
204 <p>Sets the DPI (dots per inch) for this context. Default is <code>96</code>.</p>
205
206 </div>
207 <h2 id="set_language">set_language</h2>
208 <div id="set_language_CONTENT">
209 <pre> SDL::Pango::set_language($context, $language);
210
211 </pre>
212 <p>Sets the language name for this context.</p>
213 <p>See <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php">ISO639-2</a>.</p>
214 <p>Example:</p>
215 <pre> SDL::Pango::set_language($context, &quot;en&quot;);
216
217 </pre>
218
219 </div>
220 <h2 id="draw">draw</h2>
221 <div id="draw_CONTENT">
222 <pre> SDL::Pango::draw($context, $display, $x, $y);
223
224 </pre>
225 <p>Draws the text or markup to an existing surface at position <code>$x</code>/<code>$y</code>.</p>
226
227 </div>
228 <h2 id="set_surface_create_args">set_surface_create_args</h2>
229 <div id="set_surface_create_args_CONTENT">
230 <pre> SDL::Pango::set_surface_create_args($context, $flags, $bits, $r_mask, $g_mask, $b_mask, $a_mask);
231
232 </pre>
233 <p>Sets the argumet that are used when creating a surface via <a href="/SDL-Pango.html#create_surface_draw">SDL::Pango::create_surface_draw</a>.</p>
234 <p>Example:</p>
235 <pre> SDL::Pango::set_surface_create_args(
236      $context, 
237      SDL_SWSURFACE, 
238      32, 
239      0xFF000000, 
240      0x00FF0000, 
241      0x0000FF00, 
242      0x000000FF
243  );
244
245 </pre>
246
247 </div>
248 <h2 id="create_surface_draw">create_surface_draw</h2>
249 <div id="create_surface_draw_CONTENT">
250 <pre> my $surface = SDL::Pango::create_surface_draw($context);
251
252 </pre>
253 <p>Creates a new surface and draws the text/markup. You can specify the attributes of the surfaces using <a href="/SDL-Pango.html#set_surface_create_args">SDL::Pango::set_surface_create_args</a>.</p>
254
255 </div>
256 <h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
257 <div id="AUTHOR_CONTENT">
258 <p>Tobias Leich [FROGGS]</p>
259
260 </div>
261 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
262 <div id="SEE_ALSO_CONTENT">
263 <p><a href="SDL-Pango-Context.html">SDL::Pango::Context</a>, <a href="SDL-Video.html">SDL::Video</a>, <a href="SDL-Surface.html">SDL::Surface</a>, <a href="SDL-TTF.html">SDL::TTF</a></p>
264
265 </div>
266 </div>