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