Commit | Line | Data |
b41abbd6 |
1 | #!perl |
2 | use strict; |
3 | use warnings; |
4 | use SDL::Config; |
5 | use Test::More; |
6 | |
7 | if ( SDL::Config->has('SDL_ttf') ) { |
8 | plan( tests => 10 ); |
9 | } else { |
10 | plan( skip_all => 'SDL_ttf support not compiled' ); |
11 | } |
12 | |
13 | use_ok('SDL'); |
14 | use_ok('SDL::Color'); |
15 | use_ok('SDL::Surface'); |
16 | use_ok('SDL::TTF_Font'); |
17 | |
18 | SDL::TTF_Init(); |
19 | |
20 | my $ttf_font = SDL::TTF_OpenFont( 'test/data/aircut3.ttf', 12 ); |
21 | isa_ok( $ttf_font, 'SDL::TTF_Font' ); |
22 | my ( $w, $h ) = @{ SDL::TTF_SizeText( $ttf_font, 'Hello!' ) }; |
b9125226 |
23 | is( ($w == 27) || ($w == 28), 1, '"Hello!" has width 27' ); |
24 | is( ($h == 14) || ($h == 15), 1, '"Hello!" has width 14' ); |
b41abbd6 |
25 | |
26 | my $surface = SDL::TTF_RenderText_Blended( $ttf_font, 'Hello!', |
27 | SDL::Color->new( 255, 0, 0 ) ); |
28 | isa_ok( $surface, 'SDL::Surface' ); |
4865f3af |
29 | ($w,$h) = ( $surface->w, $surface->h) ; |
30 | is( ($w == 27) || ($w == 28), 1 ,'Surface has width 27' ); |
31 | is( ($h == 14) || ($h == 15), 1, 'Surface has width 14' ); |
b41abbd6 |
32 | |
33 | SDL::TTF_Quit(); |