GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
pods::SDL::Pango(3) User Contributed Perl Documentation pods::SDL::Pango(3)

SDL::Pango - Text rendering engine

Pango

 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);

The constants are exported by default. You can avoid this by doing:

 use SDL::Pango ();

and access them directly:

 SDL::Pango::SDLPANGO_DIRECTION_NEUTRAL;

or by choosing the export tags below:

Export tag: ':align'

SDLPANGO_ALIGN_LEFT
Left alignment
SDLPANGO_ALIGN_CENTER
Centered
SDLPANGO_ALIGN_RIGHT
Right alignment

Export tag: ':direction'

SDLPANGO_DIRECTION_LTR
Left to right
SDLPANGO_DIRECTION_RTL
Right to left
SDLPANGO_DIRECTION_WEAK_LTR
Left to right (weak)
SDLPANGO_DIRECTION_WEAK_RTL
Right to left (weak)
SDLPANGO_DIRECTION_NEUTRAL
Neutral

 SDL::Pango::init();

Initialize the Glib and Pango API. This must be called before using other functions in this library, excepting SDL::Pango::was_init. SDL does not have to be initialized before this call.

Returns: always 0.

 my $was_init = SDL::Pango::was_init();

Query 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.

 SDL::Pango::set_default_color($context, $foreground, $background);
 SDL::Pango::set_default_color($context, $r1, $g1, $b1, $a1, $r2, $g2, $b2, $a2);

Sets 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.

 SDL::Pango::set_minimum_size($context, $width, $height);

Sets the minimum size of the drawing rectangle.

 SDL::Pango::set_text($context, $text, $length);
 SDL::Pango::set_text($context, $text, $length, $alignment);

Set 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_CENTER
  • SDLPANGO_ALIGN_RIGHT

 SDL::Pango::set_markup($context, $text, $length);

Set markup text to context. Text must be utf-8. $length chars will be rendered, pass "-1" to render the whole text.

See PangoMarkupFormat <http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html> for a description about the markup format.

 my $w = SDL::Pango::get_layout_width($context);

Returns the width of the resulting surface of the given text/markup for this context.

 my $h = SDL::Pango::get_layout_height($context);

Returns the height of the resulting surface of the given text/markup for this context.

 SDL::Pango::set_base_direction($context, $direction);

Sets the direction of the text to either left-to-right or right-to-left.

See "CONSTANTS".

 SDL::Pango::set_dpi($context, $dpi_x, $dpi_y);

Sets the DPI (dots per inch) for this context. Default is 96.

 SDL::Pango::set_language($context, $language);

Sets the language name for this context.

See ISO639-2 <http://www.loc.gov/standards/iso639-2/php/code_list.php>.

Example:

 SDL::Pango::set_language($context, "en");

 SDL::Pango::draw($context, $display, $x, $y);

Draws the text or markup to an existing surface at position $x/$y.

 SDL::Pango::set_surface_create_args($context, $flags, $bits, $r_mask, $g_mask, $b_mask, $a_mask);

Sets the argument 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
 );

 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.

See "AUTHORS" in SDL.

SDL::Pango::Context, SDL::Video, SDL::Surface, SDL::TTF
2022-06-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.