/lib/pods/SDL/Pango.pod

http://github.com/PerlGameDev/SDL · Unknown · 243 lines · 135 code · 108 blank · 0 comment · 0 complexity · 69093bef4c317f9d8a71faf1914a60cc MD5 · raw file

  1. =pod
  2. =head1 NAME
  3. SDL::Pango - Text rendering engine
  4. =head1 CATEGORY
  5. Pango
  6. =head1 SYNOPSIS
  7. use SDL;
  8. use SDL::Color;
  9. use SDL::Surface;
  10. use SDL::Overlay;
  11. use SDL::Rect;
  12. use SDL::Video;
  13. use SDL::PixelFormat;
  14. use SDL::Pango;
  15. use SDL::Pango::Context;
  16. SDL::Pango::init();
  17. my $context = SDL::Pango::Context->new;
  18. SDL::Pango::set_default_color($context, 0xA7C344FF, 0);
  19. SDL::Pango::set_markup($context, 'Hello <b>W<span foreground="red">o</span><i>r</i><u>l</u>d</b>!', -1);
  20. SDL::init(SDL_INIT_VIDEO);
  21. my $display = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE);
  22. my $bg = SDL::Video::map_RGB($display->format, 0x12, 0x22, 0x45);
  23. SDL::Video::fill_rect($display, SDL::Rect->new(0, 0, 640, 480), $bg);
  24. my $surface = SDL::Pango::create_surface_draw($context);
  25. SDL::Video::blit_surface($surface, SDL::Rect->new(0, 0, 640, 480), $display, SDL::Rect->new(0, 0, 640, 480));
  26. SDL::Video::update_rect($display, 0, 0, 0, 0);
  27. SDL::delay(2000);
  28. =head1 CONSTANTS
  29. The constants are exported by default. You can avoid this by doing:
  30. use SDL::Pango ();
  31. and access them directly:
  32. SDL::Pango::SDLPANGO_DIRECTION_NEUTRAL;
  33. or by choosing the export tags below:
  34. Export tag: ':align'
  35. =over 4
  36. =item SDLPANGO_ALIGN_LEFT
  37. Left alignment
  38. =item SDLPANGO_ALIGN_CENTER
  39. Centered
  40. =item SDLPANGO_ALIGN_RIGHT
  41. Right alignment
  42. =back
  43. Export tag: ':direction'
  44. =over 4
  45. =item SDLPANGO_DIRECTION_LTR
  46. Left to right
  47. =item SDLPANGO_DIRECTION_RTL
  48. Right to left
  49. =item SDLPANGO_DIRECTION_WEAK_LTR
  50. Left to right (weak)
  51. =item SDLPANGO_DIRECTION_WEAK_RTL
  52. Right to left (weak)
  53. =item SDLPANGO_DIRECTION_NEUTRAL
  54. Neutral
  55. =back
  56. =head1 METHODS
  57. =head2 init
  58. SDL::Pango::init();
  59. Initialize the Glib and Pango API. This must be called before using other functions in this library, excepting L<SDL::Pango::was_init|SDL::Pango/"was_init">.
  60. SDL does not have to be initialized before this call.
  61. Returns: always C<0>.
  62. =head2 was_init
  63. my $was_init = SDL::Pango::was_init();
  64. Query the initialization status of the Glib and Pango API. You may, of course, use this before L<SDL::Pango::init|SDL::Pango/"init"> to avoid initializing twice
  65. in a row.
  66. Returns: Non-zero when already initialized. Zero when not initialized.
  67. =head2 set_default_color
  68. SDL::Pango::set_default_color($context, $foreground, $background);
  69. SDL::Pango::set_default_color($context, $r1, $g1, $b1, $a1, $r2, $g2, $b2, $a2);
  70. Sets default foreground and background color when rendering text and markup.
  71. 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
  72. background.
  73. =head2 set_minimum_size
  74. SDL::Pango::set_minimum_size($context, $width, $height);
  75. Sets the minimum size of the drawing rectangle.
  76. =head2 set_text
  77. SDL::Pango::set_text($context, $text, $length);
  78. SDL::Pango::set_text($context, $text, $length, $alignment);
  79. Set plain text to context. Text must be utf-8. C<$length> chars will be rendered, pass C<-1> to render the whole text.
  80. C<$alignment> can be:
  81. =over 4
  82. =item *
  83. SDLPANGO_ALIGN_LEFT (default)
  84. =item *
  85. SDLPANGO_ALIGN_CENTER
  86. =item *
  87. SDLPANGO_ALIGN_RIGHT
  88. =back
  89. =head2 set_markup
  90. SDL::Pango::set_markup($context, $text, $length);
  91. Set markup text to context. Text must be utf-8. C<$length> chars will be rendered, pass C<-1> to render the whole text.
  92. See L<PangoMarkupFormat|http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html> for a description about the markup format.
  93. =head2 get_layout_width
  94. my $w = SDL::Pango::get_layout_width($context);
  95. Returns the width of the resulting surface of the given text/markup for this context.
  96. =head2 get_layout_height
  97. my $h = SDL::Pango::get_layout_height($context);
  98. Returns the height of the resulting surface of the given text/markup for this context.
  99. =head2 set_base_direction
  100. SDL::Pango::set_base_direction($context, $direction);
  101. Sets the direction of the text to either left-to-right or right-to-left.
  102. See L</CONSTANTS>.
  103. =head2 set_dpi
  104. SDL::Pango::set_dpi($context, $dpi_x, $dpi_y);
  105. Sets the DPI (dots per inch) for this context. Default is C<96>.
  106. =head2 set_language
  107. SDL::Pango::set_language($context, $language);
  108. Sets the language name for this context.
  109. See L<ISO639-2|http://www.loc.gov/standards/iso639-2/php/code_list.php>.
  110. Example:
  111. SDL::Pango::set_language($context, "en");
  112. =head2 draw
  113. SDL::Pango::draw($context, $display, $x, $y);
  114. Draws the text or markup to an existing surface at position C<$x>/C<$y>.
  115. =head2 set_surface_create_args
  116. SDL::Pango::set_surface_create_args($context, $flags, $bits, $r_mask, $g_mask, $b_mask, $a_mask);
  117. Sets the argument that are used when creating a surface via L<SDL::Pango::create_surface_draw|SDL::Pango/"create_surface_draw">.
  118. Example:
  119. SDL::Pango::set_surface_create_args(
  120. $context,
  121. SDL_SWSURFACE,
  122. 32,
  123. 0xFF000000,
  124. 0x00FF0000,
  125. 0x0000FF00,
  126. 0x000000FF
  127. );
  128. =head2 create_surface_draw
  129. my $surface = SDL::Pango::create_surface_draw($context);
  130. Creates a new surface and draws the text/markup. You can specify the attributes of the surfaces using L<SDL::Pango::set_surface_create_args|SDL::Pango/"set_surface_create_args">.
  131. =head1 AUTHORS
  132. See L<SDL/AUTHORS>.
  133. =head1 SEE ALSO
  134. L<SDL::Pango::Context>, L<SDL::Video>, L<SDL::Surface>, L<SDL::TTF>
  135. =cut