pods::SDL::Pango(3pm)
π NAME π
hey bestie, welcome to pods::SDL::Pango(3pm) from the User Contributed Perl Documentation collection π«Ά this is literally SDL::Pango β the Text rendering engine. main character energy fr fr β¨
πΈ CATEGORY πΈ
Pango π
β¨ SYNOPSIS β¨
okay so here's the whole vibe, no cap π
use SDL;
use SDL::Color;
use SDL::Surface;
use SDL::Overlay;
use SDL::Rect;
use SDL::Video;
use SDL::PixelFormat;
use SDL::Pango;
use SDL::Pango::Context;
SDL::Pango::init();
my $context = SDL::Pango::Context->new;
SDL::Pango::set_default_color($context, 0xA7C344FF, 0);
SDL::Pango::set_markup($context, 'Hello <b>W<span foreground="red">o</span><i>r</i><u>l</u>d</b>!', -1);
SDL::init(SDL_INIT_VIDEO);
my $display = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE);
my $bg = SDL::Video::map_RGB($display->format, 0x12, 0x22, 0x45);
SDL::Video::fill_rect($display, SDL::Rect->new(0, 0, 640, 480), $bg);
my $surface = SDL::Pango::create_surface_draw($context);
SDL::Video::blit_surface($surface, SDL::Rect->new(0, 0, 640, 480), $display, SDL::Rect->new(0, 0, 640, 480));
SDL::Video::update_rect($display, 0, 0, 0, 0);
SDL::delay(2000);
π CONSTANTS π
so these constants are exported by default, bestie π you can avoid that by doing:
use SDL::Pango ();
and then access them directly like this:
SDL::Pango::SDLPANGO_DIRECTION_NEUTRAL;
or you can choose the export tags below π¦
Export tag: ':align'
SDLPANGO_ALIGN_LEFTβ Left alignmentSDLPANGO_ALIGN_CENTERβ CenteredSDLPANGO_ALIGN_RIGHTβ Right alignment
Export tag: ':direction'
SDLPANGO_DIRECTION_LTRβ Left to rightSDLPANGO_DIRECTION_RTLβ Right to leftSDLPANGO_DIRECTION_WEAK_LTRβ Left to right (weak)SDLPANGO_DIRECTION_WEAK_RTLβ Right to left (weak)SDLPANGO_DIRECTION_NEUTRALβ Neutral
π METHODS π
init
SDL::Pango::init();
okay so this initializes the Glib and Pango API. it must be called before using other functions in this library, excepting SDL::Pango::was_init β οΈ and ngl, SDL does not have to be initialized before this call.
Returns: always 0.
was_init
my $was_init = SDL::Pango::was_init();
queries the initialization status of the Glib and Pango API. you may, of course, use this before SDL::Pango::init to avoid initializing twice in a row π
Returns: Non-zero when already initialized. Zero when not initialized.
set_default_color
SDL::Pango::set_default_color($context, $foreground, $background);
SDL::Pango::set_default_color($context, $r1, $g1, $b1, $a1, $r2, $g2, $b2, $a2);
sets the default foreground and background color when rendering text and markup π¨
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 background. periodt.
set_minimum_size
SDL::Pango::set_minimum_size($context, $width, $height);
sets the minimum size of the drawing rectangle π
set_text
SDL::Pango::set_text($context, $text, $length);
SDL::Pango::set_text($context, $text, $length, $alignment);
sets plain text to context. text must be utf-8 π $length chars will be rendered, pass -1 to render the whole text.
$alignment can be:
SDLPANGO_ALIGN_LEFT(default)SDLPANGO_ALIGN_CENTERSDLPANGO_ALIGN_RIGHT
set_markup
SDL::Pango::set_markup($context, $text, $length);
sets markup text to context. text must be utf-8 β¨ $length chars will be rendered, pass -1 to render the whole text.
see PangoMarkupFormat at http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html for a description about the markup format π«Ά
get_layout_width
my $w = SDL::Pango::get_layout_width($context);
returns the width of the resulting surface of the given text/markup for this context π
get_layout_height
my $h = SDL::Pango::get_layout_height($context);
returns the height of the resulting surface of the given text/markup for this context π
set_base_direction
SDL::Pango::set_base_direction($context, $direction);
sets the direction of the text to either left-to-right or right-to-left ππ
see "CONSTANTS".
set_dpi
SDL::Pango::set_dpi($context, $dpi_x, $dpi_y);
sets the DPI (dots per inch) for this context. default is 96 π
set_language
SDL::Pango::set_language($context, $language);
sets the language name for this context π
see ISO639-2 at http://www.loc.gov/standards/iso639-2/php/code_list.php.
example:
SDL::Pango::set_language($context, "en");
draw
SDL::Pango::draw($context, $display, $x, $y);
draws the text or markup to an existing surface at position $x/$y ποΈ
set_surface_create_args
SDL::Pango::set_surface_create_args($context, $flags, $bits, $r_mask, $g_mask, $b_mask, $a_mask);
sets the arguments that are used when creating a surface via SDL::Pango::create_surface_draw π§
example:
SDL::Pango::set_surface_create_args(
$context,
SDL_SWSURFACE,
32,
0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF
);
create_surface_draw
my $surface = SDL::Pango::create_surface_draw($context);
creates a new surface and draws the text/markup π₯ you can specify the attributes of the surfaces using SDL::Pango::set_surface_create_args.
π¦ AUTHORS π¦
see "AUTHORS" in SDL.
π SEE ALSO π
SDL::Pango::Context, SDL::Video, SDL::Surface, SDL::TTF
that's the whole manual, bestie β perl v5.42.3, 2026-08-19, and pods::SDL::Pango(3pm) signing off π
β¨π«Ά
π¦ where this page comes from
- ubuntu stonking: libsdl-perl 2.548-6build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms