X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-TTF.html-inc;h=29189a2642a6a29dff403e352a63f11186e2d90d;hb=505f308d8b092747da8b2f5e9781475a1f06dfe8;hp=9982078618f8277f74aa7a1b1e7ab8478b56e546;hpb=3ad5a97a76d6e21cb4cea42165f5e899cf78d4f8;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-TTF.html-inc b/pages/SDL-TTF.html-inc index 9982078..29189a2 100644 --- a/pages/SDL-TTF.html-inc +++ b/pages/SDL-TTF.html-inc @@ -4,6 +4,7 @@
TTF
+The constants are exported by default. You can avoid this by doing:
+use SDL::TTF (); + + + + ++
and access them directly:
+SDL::TTF::TTF_HINTING_NORMAL; + ++
Available constants for "hinting":
+Available constants for "style":
+Note: See space-character bug. You have to upgrade libfreetype2 to at least version 2.3.5
Example:
-use SDL; - use SDL::Video; - use SDL::Color; - use SDL::TTF; - use SDL::TTF::Font; +use SDL; + use SDL::Rect; + use SDL::Video; + use SDL::Color; + use SDL::TTF; + use SDL::TTF::Font; - SDL::init(SDL_INIT_VIDEO); - - my $display = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE); - my $font = SDL::TTF::open_font('arial.ttf', '24); - my $surface = SDL::TTF::render_text_solid($font, 'Hallo!', SDL::Color->new(0xFF,0xFF,0xFF)); - - SDL::Video::blit_surface($surface, SDL::Rect->new(0, 0, 640, 480), $display, SDL::Rect->new(10, 10, 640, 480)); - SDL::Video::update_rect($display, 0, 0, 0, 0); - - SDL::delay(5000); + SDL::init(SDL_INIT_VIDEO); + SDL::TTF::init(); + my $display = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE); + my $font = SDL::TTF::open_font('test/data/aircut3.ttf', '24'); + die 'Coudnt make font '. SDL::get_error if !$font; + my $surface = SDL::TTF::render_text_solid($font, 'Hallo!', SDL::Color->new(0xFF,0xFF,0xFF)); + SDL::Video::blit_surface($surface, SDL::Rect->new(0, 0, 640, 480), $display, SDL::Rect->new(10, 10, 640, 480)); + SDL::Video::update_rect($display, 0, 0, 0, 0); + SDL::delay(5000);@@ -665,8 +698,10 @@ your display-surface. SDL::init(SDL_INIT_VIDEO); + SDL::TTF::init(); + my $display = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE); - my $font = SDL::TTF::open_font('arial.ttf', '24); + my $font = SDL::TTF::open_font('arial.ttf', '24'); my $white = SDL::Color->new(0xFF, 0xFF, 0xFF); my $black = SDL::Color->new(0x00, 0x00, 0x00); my $surface = SDL::TTF::render_text_solid($font, 'Hallo!', $white, $black); @@ -726,8 +761,10 @@ your display-surface. SDL::init(SDL_INIT_VIDEO); + SDL::TTF::init(); + my $display = SDL::Video::set_video_mode(640, 480, 32, SDL_SWSURFACE); - my $font = SDL::TTF::open_font('arial.ttf', '24); + my $font = SDL::TTF::open_font('arial.ttf', '24'); my $surface = SDL::TTF::render_text_blended($font, 'Hallo!', SDL::Color->new(0xFF,0xFF,0xFF)); SDL::Video::blit_surface($surface, SDL::Rect->new(0, 0, 640, 480), $display, SDL::Rect->new(10, 10, 640, 480));