SDL

 view release on metacpan or  search on metacpan

CHANGELOG  view on Meta::CPAN

	- Using dummy audiodriver for tests so no sound is played [#163] [FROGGS]
	- POGL example added
	- Fixed fail due to to strict test for texture_polygon in SDL::GFX
	- Created SDLx::FPS [Blaizer]

* 2.408 Sun June 13 2010
	- Added File::ShareDir as a dep
	- TODO'd temporary test cases

* 2.407 Wed June 02 2010
	- Minor fix on BOM marks in test files

* 2.406 Tues May 18 2010
	- Fixed SDL::Video::list_modes(), it returns now arrayref to SDL::Rects [FROGGS]
	- Updated docs [Blaizer]
	- Removed deprecated modules [kthakore, FROGGS]

* 2.405 Wed May 05 2010
	- Conditional compile on glu.h header [kthakore] {ticket 131}
	- Documentation cleanup [bricas, kthakore]
	- Remove usesages of 'new SDL...' [bricas]

lib/pods/SDL/TTF.pod  view on Meta::CPAN

L<SDL::RWOps>-object will be freed by SDL_ttf library. Don't do this, perl will free this object for you.

=head2 Attributes

=head3 Global attributes

=head4 byte_swapped_unicode

 SDL::TTF::byte_swapped_unicode( $bool );

This function tells SDL_ttf whether UNICODE (2 bytes per character) text is generally byteswapped. A C<UNICODE_BOM_NATIVE> or 
C<UNICODE_BOM_SWAPPED> character in a string will temporarily override this setting for the remainder of that string, however this setting 
will be restored for the next one. The default mode is non-swapped, native endianness of the CPU.

=head3 Font style

=head4 get_font_style

 SDL::TTF::get_font_style($font);

Returns: The style as a bitmask composed of the following masks:

lib/pods/SDL/TTF.pod  view on Meta::CPAN

=head3 Glyphs

=head4 glyph_is_provided

 my $glyph_is_provided = SDL::TTF::glyph_is_provided($font, $unicode_char);

Get the status of the availability of the glyph from the loaded font.

Returns: the index of the glyph in font, or 0 for an undefined character code.

B<Note>: You have to pass this unicode character either as UTF16/UCS-2 big endian without BOM, or with BOM as UTF16/UCS-2 big/little endian.

B<Note>: at least SDL_ttf 2.0.10 needed

Example:

 print("We have this char!\n") if SDL::TTF::glyph_is_provided($font, "\0M");

=head4 glyph_metrics

 my @glyph_metrics = @{ SDL::TTF::glyph_metrics($font, $unicode_char) };

Get desired glyph metrics of the UNICODE char from the loaded font.

See also: L<The FreeType2 Documentation Tutorial|http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html>

B<Note>: You have to pass this unicode character either as UTF16/UCS-2 big endian without BOM, or with BOM as UTF16/UCS-2 big/little endian.

Example:

 my ($minx, $maxx, $miny, $maxy, $advance) = @{ SDL::TTF::glyph_metrics($font, "\0M") };

=head3 Text metrics

=head4 size_text

 my ($width, $height) = @{ SDL::TTF::size_text($font, $text) };

lib/pods/SDL/TTF.pod  view on Meta::CPAN


 my ($width, $height) = @{ SDL::TTF::size_unicode($font, $text) };

Calculate the resulting surface size of the UNICODE encoded text rendered using C<$font>. No actual rendering is done, however correct kerning 
is done to get the actual width. The height returned in h is the same as you can get using L<SDL::TTF::font_height|SDL::TTF/"font_height">.

C<$text> has to be:

=over 4

=item UTF16BE without BOM

"hello" will look like "\0h\0e\0l\0l\0o"

=item UTF16BE with BOM

"hello" will look like "\xFE\xFF\0h\0e\0l\0l\0o"

=item UTF16LE with BOM

"hello" will look like "\xFF\xFEh\0e\0l\0l\0o\0"

=back

You may use Unicode::String for this.

=head2 Font Rendering

=head3 Solid

src/TTF/TTF.xs  view on Meta::CPAN

	unicode[j] = 0;
	
	return unicode;
}

static Uint16 *utf16_to_UNICODE(SV *sv)
{
	STRLEN len;
	char *text      = SvPV(sv, len);
	len            /= 2;                                      /* 1-Byte chars to 2-Byte Uint16 */
	Uint16 *unicode = safemalloc((len + 2) * sizeof(Uint16)); /* length = BOM + characters + NULL */
	int i;

	/* UTF-16 Big Endian with BOM */
	if((Uint8)text[0] == 0xFE && (Uint8)text[1] == 0xFF)
	{
		for( i = 0; i < len; i++ )
		{
			unicode[i] = ((Uint8)text[i * 2] << 8) | (Uint8)text[i * 2 + 1];
		}
		unicode[i] = 0;
	}
	
	else
	/* UTF-16 Little Endian with BOM */
	if((Uint8)text[0] == 0xFF && (Uint8)text[1] == 0xFE)
	{
		for( i = 0; i < len; i++ )
		{
			unicode[i] = ((Uint8)text[i * 2 + 1] << 8) | (Uint8)text[i * 2];
		}
		unicode[i] = 0;
	}
	
	else /* everything without BOM is treated as UTF-16 Big Endian */
	{
		unicode[0] = 0xFEFF; /* we have to pass it as UTF-16 Big Endian */
		for( i = 0; i <= len; i++ )
		{
			unicode[i + 1] = (text[i * 2] << 8) | text[i * 2 + 1];
		}
		unicode[i] = 0;
	}

	return unicode;



( run in 0.524 second using v1.01-cache-2.11-cpan-131fc08a04b )