constants in docs
[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 access them directly:</p>
82 <pre> SDL::Pango::SDLPANGO_DIRECTION_NEUTRAL;
83
84 </pre>
85 <p>Available constants:</p>
86 <dl>
87         <dt>SDLPANGO_DIRECTION_LTR</dt>
88         <dd>
89                 <p>Left to right</p>
90         </dd>
91         <dt>SDLPANGO_DIRECTION_RTL</dt>
92         <dd>
93                 <p>Right to left</p>
94         </dd>
95         <dt>SDLPANGO_DIRECTION_WEAK_LTR</dt>
96         <dd>
97                 <p>Left to right (weak)</p>
98         </dd>
99         <dt>SDLPANGO_DIRECTION_WEAK_RTL</dt>
100         <dd>
101                 <p>Right to left (weak)</p>
102         </dd>
103         <dt>SDLPANGO_DIRECTION_NEUTRAL</dt>
104         <dd>
105                 <p>Neutral</p>
106         </dd>
107 </dl>
108
109 </div>
110 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
111 <div id="METHODS_CONTENT">
112
113 </div>
114 <h2 id="init">init</h2>
115 <div id="init_CONTENT">
116 <pre> SDL::Pango::init();
117
118 </pre>
119 <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>. 
120 SDL does not have to be initialized before this call.</p>
121 <p>Returns: always <code>0</code>. </p>
122
123 </div>
124 <h2 id="was_init">was_init</h2>
125 <div id="was_init_CONTENT">
126 <pre> my $was_init = SDL::Pango::was_init();
127
128 </pre>
129 <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 
130 in a row.</p>
131 <p>Returns: Non-zero when already initialized. Zero when not initialized.</p>
132
133 </div>
134 <h2 id="set_default_color">set_default_color</h2>
135 <div id="set_default_color_CONTENT">
136 <pre> SDL::Pango::set_default_color($context, $foreground, $background);
137  SDL::Pango::set_default_color($context, $r1, $g1, $b1, $a1, $r2, $g2, $b2, $a2);
138
139 </pre>
140 <p>Sets default foreground and background color when rendering text and markup.</p>
141 <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 
142 background.</p>
143
144 </div>
145 <h2 id="set_minimum_size">set_minimum_size</h2>
146 <div id="set_minimum_size_CONTENT">
147 <pre> SDL::Pango::set_minimum_size($context, $width, $height);
148
149 </pre>
150 <p>Sets the minimum size of the drawing rectangle.</p>
151
152 </div>
153 <h2 id="set_text">set_text</h2>
154 <div id="set_text_CONTENT">
155 <pre> SDL::Pango::set_text($context, $text, $length);
156
157 </pre>
158 <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>
159
160 </div>
161 <h2 id="set_markup">set_markup</h2>
162 <div id="set_markup_CONTENT">
163 <pre> SDL::Pango::set_markup($context, $text, $length);
164
165 </pre>
166 <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>
167 <p>See <a href="http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html">PangoMarkupFormat</a> for a description about the markup format.</p>
168
169 </div>
170 <h2 id="get_layout_width">get_layout_width</h2>
171 <div id="get_layout_width_CONTENT">
172 <pre> my $w = SDL::Pango::get_layout_width($context);
173
174 </pre>
175 <p>Returns the width of the resulting surface of the given text/markup for this context.</p>
176
177 </div>
178 <h2 id="get_layout_height">get_layout_height</h2>
179 <div id="get_layout_height_CONTENT">
180 <pre> my $h = SDL::Pango::get_layout_height($context);
181
182 </pre>
183 <p>Returns the height of the resulting surface of the given text/markup for this context.</p>
184
185 </div>
186 <h2 id="set_base_direction">set_base_direction</h2>
187 <div id="set_base_direction_CONTENT">
188 <pre> SDL::Pango::set_base_direction($context, $direction);
189
190 </pre>
191 <p>Sets the direction of the text to either left-to-right or right-to-left.</p>
192 <p>See <a href="#CONSTANTS">CONSTANTS</a>.</p>
193
194 </div>
195 <h2 id="set_dpi">set_dpi</h2>
196 <div id="set_dpi_CONTENT">
197 <pre> SDL::Pango::set_dpi($context, $dpi_x, $dpi_y);
198
199 </pre>
200 <p>Sets the DPI (dots per inch) for this context. Default is <code>96</code>.</p>
201
202 </div>
203 <h2 id="set_language">set_language</h2>
204 <div id="set_language_CONTENT">
205 <pre> SDL::Pango::set_language($context, $language);
206
207 </pre>
208 <p>Sets the language name for this context.</p>
209 <p>See <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php">ISO639-2</a>.</p>
210 <p>Example:</p>
211 <pre> SDL::Pango::set_language($context, &quot;en&quot;);
212
213 </pre>
214
215 </div>
216 <h2 id="draw">draw</h2>
217 <div id="draw_CONTENT">
218 <pre> SDL::Pango::draw($context, $display, $x, $y);
219
220 </pre>
221 <p>Draws the text or markup to an existing surface at position <code>$x</code>/<code>$y</code>.</p>
222
223 </div>
224 <h2 id="set_surface_create_args">set_surface_create_args</h2>
225 <div id="set_surface_create_args_CONTENT">
226 <pre> SDL::Pango::set_surface_create_args($context, $flags, $bits, $r_mask, $g_mask, $b_mask, $a_mask);
227
228 </pre>
229 <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>
230 <p>Example:</p>
231 <pre> SDL::Pango::set_surface_create_args(
232      $context, 
233      SDL_SWSURFACE, 
234      32, 
235      0xFF000000, 
236      0x00FF0000, 
237      0x0000FF00, 
238      0x000000FF
239  );
240
241 </pre>
242
243 </div>
244 <h2 id="create_surface_draw">create_surface_draw</h2>
245 <div id="create_surface_draw_CONTENT">
246 <pre> my $surface = SDL::Pango::create_surface_draw($context);
247
248 </pre>
249 <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>
250
251 </div>
252 <h1 id="AUTHOR">AUTHOR</h1><p><a href="#TOP" class="toplink">Top</a></p>
253 <div id="AUTHOR_CONTENT">
254 <p>Tobias Leich [FROGGS]</p>
255
256 </div>
257 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
258 <div id="SEE_ALSO_CONTENT">
259 <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>
260
261 </div>
262 </div>