1SDL::Pango(3) User Contributed Perl Documentation SDL::Pango(3)
2
3
4
6 SDL::Pango - Text rendering engine
7
9 Pango
10
12 use SDL;
13 use SDL::Color;
14 use SDL::Surface;
15 use SDL::Overlay;
16 use SDL::Rect;
17 use SDL::Video;
18 use SDL::PixelFormat;
19 use SDL::Pango;
20 use SDL::Pango::Context;
21
22 SDL::Pango::init();
23
24 my $context = SDL::Pango::Context->new;
25 SDL::Pango::set_default_color($context, 0xA7C344FF, 0);
26 SDL::Pango::set_markup($context, 'Hello <b>W<span foreground="red">o</span><i>r</i><u>l</u>d</b>!', -1);
27
28 SDL::init(SDL_INIT_VIDEO);
29
30 my $display = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE);
31 my $bg = SDL::Video::map_RGB($display->format, 0x12, 0x22, 0x45);
32 SDL::Video::fill_rect($display, SDL::Rect->new(0, 0, 640, 480), $bg);
33
34 my $surface = SDL::Pango::create_surface_draw($context);
35 SDL::Video::blit_surface($surface, SDL::Rect->new(0, 0, 640, 480), $display, SDL::Rect->new(0, 0, 640, 480));
36
37 SDL::Video::update_rect($display, 0, 0, 0, 0);
38 SDL::delay(2000);
39
41 The constants are exported by default. You can avoid this by doing:
42
43 use SDL::Pango ();
44
45 and access them directly:
46
47 SDL::Pango::SDLPANGO_DIRECTION_NEUTRAL;
48
49 or by choosing the export tags below:
50
51 Export tag: ':align'
52
53 SDLPANGO_ALIGN_LEFT
54 Left alignment
55
56 SDLPANGO_ALIGN_CENTER
57 Centered
58
59 SDLPANGO_ALIGN_RIGHT
60 Right alignment
61
62 Export tag: ':direction'
63
64 SDLPANGO_DIRECTION_LTR
65 Left to right
66
67 SDLPANGO_DIRECTION_RTL
68 Right to left
69
70 SDLPANGO_DIRECTION_WEAK_LTR
71 Left to right (weak)
72
73 SDLPANGO_DIRECTION_WEAK_RTL
74 Right to left (weak)
75
76 SDLPANGO_DIRECTION_NEUTRAL
77 Neutral
78
80 init
81 SDL::Pango::init();
82
83 Initialize the Glib and Pango API. This must be called before using
84 other functions in this library, excepting SDL::Pango::was_init. SDL
85 does not have to be initialized before this call.
86
87 Returns: always 0.
88
89 was_init
90 my $was_init = SDL::Pango::was_init();
91
92 Query the initialization status of the Glib and Pango API. You may, of
93 course, use this before SDL::Pango::init to avoid initializing twice in
94 a row.
95
96 Returns: Non-zero when already initialized. Zero when not initialized.
97
98 set_default_color
99 SDL::Pango::set_default_color($context, $foreground, $background);
100 SDL::Pango::set_default_color($context, $r1, $g1, $b1, $a1, $r2, $g2, $b2, $a2);
101
102 Sets default foreground and background color when rendering text and
103 markup.
104
105 You can call it with either 2 color-parameters (32-bit RRGGBBAA
106 values), or with 4 separate values for foreground and 4 separate values
107 for background.
108
109 set_minimum_size
110 SDL::Pango::set_minimum_size($context, $width, $height);
111
112 Sets the minimum size of the drawing rectangle.
113
114 set_text
115 SDL::Pango::set_text($context, $text, $length);
116 SDL::Pango::set_text($context, $text, $length, $alignment);
117
118 Set plain text to context. Text must be utf-8. $length chars will be
119 rendered, pass "-1" to render the whole text.
120
121 $alignment can be:
122
123 · SDLPANGO_ALIGN_LEFT (default)
124
125 · SDLPANGO_ALIGN_CENTER
126
127 · SDLPANGO_ALIGN_RIGHT
128
129 set_markup
130 SDL::Pango::set_markup($context, $text, $length);
131
132 Set markup text to context. Text must be utf-8. $length chars will be
133 rendered, pass "-1" to render the whole text.
134
135 See PangoMarkupFormat
136 <http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html>
137 for a description about the markup format.
138
139 get_layout_width
140 my $w = SDL::Pango::get_layout_width($context);
141
142 Returns the width of the resulting surface of the given text/markup for
143 this context.
144
145 get_layout_height
146 my $h = SDL::Pango::get_layout_height($context);
147
148 Returns the height of the resulting surface of the given text/markup
149 for this context.
150
151 set_base_direction
152 SDL::Pango::set_base_direction($context, $direction);
153
154 Sets the direction of the text to either left-to-right or right-to-
155 left.
156
157 See "CONSTANTS".
158
159 set_dpi
160 SDL::Pango::set_dpi($context, $dpi_x, $dpi_y);
161
162 Sets the DPI (dots per inch) for this context. Default is 96.
163
164 set_language
165 SDL::Pango::set_language($context, $language);
166
167 Sets the language name for this context.
168
169 See ISO639-2 <http://www.loc.gov/standards/iso639-2/php/code_list.php>.
170
171 Example:
172
173 SDL::Pango::set_language($context, "en");
174
175 draw
176 SDL::Pango::draw($context, $display, $x, $y);
177
178 Draws the text or markup to an existing surface at position $x/$y.
179
180 set_surface_create_args
181 SDL::Pango::set_surface_create_args($context, $flags, $bits, $r_mask, $g_mask, $b_mask, $a_mask);
182
183 Sets the argument that are used when creating a surface via
184 SDL::Pango::create_surface_draw.
185
186 Example:
187
188 SDL::Pango::set_surface_create_args(
189 $context,
190 SDL_SWSURFACE,
191 32,
192 0xFF000000,
193 0x00FF0000,
194 0x0000FF00,
195 0x000000FF
196 );
197
198 create_surface_draw
199 my $surface = SDL::Pango::create_surface_draw($context);
200
201 Creates a new surface and draws the text/markup. You can specify the
202 attributes of the surfaces using SDL::Pango::set_surface_create_args.
203
205 See "AUTHORS" in SDL.
206
208 SDL::Pango::Context, SDL::Video, SDL::Surface, SDL::TTF
209
210
211
212perl v5.32.0 2020-07-28 SDL::Pango(3)