Permalink
Browse files

Merge branch 'master' of git@github.com:kthakore/SDLx-TTF

  • Loading branch information...
2 parents 0c6530f + 9367783 commit 1d3bd3c04c719ae39916fc7e55ef6eaa020e0ac5 @kthakore committed Jun 30, 2010
Showing with 7,162 additions and 96 deletions.
  1. +7 −5 Build.PL
  2. +1 −1 lib/SDLx/TTF.pm
  3. +46 −45 lib/SDLx/TTF.xs
  4. +43 −43 src/SFont.h
  5. +7,063 −0 src/ppport.h
  6. +2 −2 t/001_load.t
View
@@ -9,16 +9,18 @@ use SDL::Config;
die ' Need SDL_IMAGE installed' if !SDL::Config->has('SDL_image');
my $prefix = Alien::SDL->config('prefix');
-my $cflags = Alien::SDL->config('cflags');
-$cflags = '-I'
- . File::Spec->catfile( $prefix, 'include' )
- ;
+#my $cflags = Alien::SDL->config('cflags');
+my $cflags = '-I'
+ . File::Spec->catfile( $prefix, 'include' );
$cflags .= ' -fnested-functions' if $^O =~ /darwin/;
+my @cflags = ExtUtils::CBuilder->new->split_like_shell( $cflags );
+
my @linkers = ExtUtils::CBuilder->new->split_like_shell(Alien::SDL->config('libs', '-lSDL_image'));
my $builder = Module::Build->new(
module_name => 'SDLx::TTF',
+ dist_name => 'SDLx::TTF',
dist_author => 'Kartik Thakore <kthakore@cpan.org>',
dist_version_from => 'lib/SDLx/TTF.pm',
requires =>
@@ -33,7 +35,7 @@ my $builder = Module::Build->new(
build_requires => {
'Alien::SDL' => '1.3'
},
- extra_compiler_flags => [ $cflags ],
+ extra_compiler_flags => \@cflags ,
extra_linker_flags => \@linkers,
c_source => 'src',
license => 'perl'
View
@@ -45,7 +45,7 @@ SDLx::TTF - Extensions for printing text onto surfaces
use SDLx::TTF;
- use SDL::App;
+ use SDLx::App;
#Make a surface
#Select a font
View
@@ -1,36 +1,37 @@
-//
-// TTF.xs
-//
-// Original SFont code Copyright (C) Karl Bartel
-// Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
-//
-// ------------------------------------------------------------------------------
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-//
-// ------------------------------------------------------------------------------
-//
-// Please feel free to send questions, suggestions or improvements to:
-//
-// David J. Goehrig
-// dgoehrig@cpan.org
-//
+/* */
+/* TTF.xs */
+/* */
+/* Original SFont code Copyright (C) Karl Bartel */
+/* Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org> */
+/* */
+/* ------------------------------------------------------------------------------ */
+/* */
+/* This library is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU Lesser General Public */
+/* License as published by the Free Software Foundation; either */
+/* version 2.1 of the License, or (at your option) any later version. */
+/* */
+/* This library is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* Lesser General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU Lesser General Public */
+/* License along with this library; if not, write to the Free Software */
+/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
+/* */
+/* ------------------------------------------------------------------------------ */
+/* */
+/* Please feel free to send questions, suggestions or improvements to: */
+/* */
+/* David J. Goehrig */
+/* dgoehrig@cpan.org */
+/* */
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#include "ppport.h"
#ifndef aTHX_
#define aTHX_
@@ -61,15 +62,15 @@ Uint32 SFont_GetPixel(SDL_Surface *Surface, Sint32 X, Sint32 Y)
bits = ((Uint8 *)Surface->pixels)+Y*Surface->pitch+X*Bpp;
- // Get the pixel
+ /* Get the pixel */
switch(Bpp) {
case 1:
return *((Uint8 *)Surface->pixels + Y * Surface->pitch + X);
break;
case 2:
return *((Uint16 *)Surface->pixels + Y * Surface->pitch/2 + X);
break;
- case 3: { // Format/endian independent
+ case 3: { /* Format/endian independent */
Uint8 r, g, b;
r = *((bits)+Surface->format->Rshift/8);
g = *((bits)+Surface->format->Gshift/8);
@@ -129,9 +130,9 @@ void SFont_PutString2(SDL_Surface *Surface, SFont_FontInfo *Font, int x, int y,
i++;
}
else {
- // warn("-%c- %c - %u\n",228,text[i],text[i]);
+ /* warn("-%c- %c - %u\n",228,text[i],text[i]); */
ofs=(text[i]-33)*2+1;
- // warn("printing %c %d\n",text[i],ofs);
+ /* warn("printing %c %d\n",text[i],ofs); */
srcrect.w = dstrect.w = (Font->CharPos[ofs+2]+Font->CharPos[ofs+1])/2-(Font->CharPos[ofs]+Font->CharPos[ofs-1])/2;
srcrect.h = dstrect.h = Font->Surface->h-1;
srcrect.x = (Font->CharPos[ofs]+Font->CharPos[ofs-1])/2;
@@ -149,7 +150,7 @@ void SFont_PutString2(SDL_Surface *Surface, SFont_FontInfo *Font, int x, int y,
void SFont_PutString(SDL_Surface *Surface, int x, int y, char *text)
{
- // warn("putString \n");
+ /* warn("putString \n"); */
SFont_PutString2(Surface, &InternalFont, x, y, text);
}
@@ -169,7 +170,7 @@ int SFont_TextWidth2(SFont_FontInfo *Font, char *text)
i++;
}
}
-// printf ("--%d\n",x);
+/* printf ("--%d\n",x); */
return x;
}
@@ -196,8 +197,8 @@ void SFont_InternalInput( SDL_Surface *Dest, SFont_FontInfo *Font, int x, int y,
SDL_Surface *Back;
SDL_Rect rect;
int previous;
-// int ofs=(text[0]-33)*2+1;
-// int leftshift=(Font->CharPos[ofs]-Font->CharPos[ofs-1])/2;
+/* int ofs=(text[0]-33)*2+1; */
+/* int leftshift=(Font->CharPos[ofs]-Font->CharPos[ofs-1])/2; */
Back = SDL_AllocSurface(Dest->flags,
Dest->w,
@@ -214,7 +215,7 @@ void SFont_InternalInput( SDL_Surface *Dest, SFont_FontInfo *Font, int x, int y,
SFont_PutString2(Dest,Font,x,y,text);
SDL_UpdateRects(Dest, 1, &rect);
- // start input
+ /* start input */
previous=SDL_EnableUNICODE(1);
blinktimer=SDL_GetTicks();
while (ch!=SDLK_RETURN) {
@@ -229,7 +230,7 @@ void SFont_InternalInput( SDL_Surface *Dest, SFont_FontInfo *Font, int x, int y,
SDL_BlitSurface( Back, NULL, Dest, &rect);
SFont_PutString2(Dest, Font, x, y, text);
SDL_UpdateRects(Dest, 1, &rect);
-// printf("%s ## %d\n",text,strlen(text));
+/* printf("%s ## %d\n",text,strlen(text)); */
SDL_WaitEvent(&event);
}
}
@@ -239,20 +240,20 @@ void SFont_InternalInput( SDL_Surface *Dest, SFont_FontInfo *Font, int x, int y,
if (blink) {
SFont_PutString2(Dest, Font, x+SFont_TextWidth2(Font,text), y, "|");
SDL_UpdateRects(Dest, 1, &rect);
-// SDL_UpdateRect(Dest, x+SFont_TextWidth2(Font,text), y, SFont_TextWidth2(Font,"|"), Font->Surface->h);
+/* SDL_UpdateRect(Dest, x+SFont_TextWidth2(Font,text), y, SFont_TextWidth2(Font,"|"), Font->Surface->h); */
} else {
SDL_BlitSurface( Back, NULL, Dest, &rect);
SFont_PutString2(Dest, Font, x, y, text);
SDL_UpdateRects(Dest, 1, &rect);
-// SDL_UpdateRect(Dest, x-(Font->CharPos[ofs]-Font->CharPos[ofs-1])/2, y, PixelWidth, Font->Surface->h);
+/* SDL_UpdateRect(Dest, x-(Font->CharPos[ofs]-Font->CharPos[ofs-1])/2, y, PixelWidth, Font->Surface->h); */
}
}
SDL_Delay(1);
SDL_PollEvent(&event);
}
text[strlen(text)]='\0';
SDL_FreeSurface(Back);
- SDL_EnableUNICODE(previous); //restore the previous state
+ SDL_EnableUNICODE(previous); /*restore the previous state */
}
void SFont_Input2( SDL_Surface *Dest, SFont_FontInfo *Font, int x, int y, int PixelWidth, char *text)
@@ -273,7 +274,7 @@ st_new ( CLASS, filename )
char *CLASS
char *filename
CODE:
- // warn( "[xs] new" );
+ /* warn( "[xs] new" ); */
RETVAL = IMG_Load(filename);
SFont_InitFont(RETVAL);
OUTPUT:
@@ -283,7 +284,7 @@ void
st_use ( surface )
SDL_Surface *surface
CODE:
- //warn( "[xs] use" );
+ /*warn( "[xs] use" ); */
SFont_InitFont(surface);
void
@@ -293,7 +294,7 @@ st_print_string ( surface, x, y, text )
int y
char *text
CODE:
- // warn( "[xs] ps" );
+ /* warn( "[xs] ps" ); */
SFont_PutString( surface, x, y, text );
int
View
@@ -1,61 +1,61 @@
-//
-// SFont.h
-//
-// Original SFont code Copyright (C) Karl Bartel
-// Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
-//
-// ------------------------------------------------------------------------------
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-//
-// ------------------------------------------------------------------------------
-//
-// Please feel free to send questions, suggestions or improvements to:
-//
-// David J. Goehrig
-// dgoehrig@cpan.org
-//
+/* */
+/* SFont.h */
+/* */
+/* Original SFont code Copyright (C) Karl Bartel */
+/* Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org> */
+/* */
+/* ------------------------------------------------------------------------------ */
+/* */
+/* This library is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU Lesser General Public */
+/* License as published by the Free Software Foundation; either */
+/* version 2.1 of the License, or (at your option) any later version. */
+/* */
+/* This library is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* Lesser General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU Lesser General Public */
+/* License along with this library; if not, write to the Free Software */
+/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
+/* */
+/* ------------------------------------------------------------------------------ */
+/* */
+/* Please feel free to send questions, suggestions or improvements to: */
+/* */
+/* David J. Goehrig */
+/* dgoehrig@cpan.org */
+/* */
#include <SDL/SDL.h>
#ifdef __cplusplus
extern "C" {
#endif
-// Delcare one variable of this type for each font you are using.
-// To load the fonts, load the font image into YourFont->Surface
-// and call InitFont( YourFont );
+/* Delcare one variable of this type for each font you are using. */
+/* To load the fonts, load the font image into YourFont->Surface */
+/* and call InitFont( YourFont ); */
typedef struct {
SDL_Surface *Surface;
int CharPos[512];
int h;
} SFont_FontInfo;
-// Initializes the font
-// Font: this contains the suface with the font.
-// The font must be loaded before using this function.
+/* Initializes the font */
+/* Font: this contains the suface with the font. */
+/* The font must be loaded before using this function. */
void InitFont (SDL_Surface *Font);
void InitFont2(SFont_FontInfo *Font);
-// Blits a string to a surface
-// Destination: the suface you want to blit to
-// text: a string containing the text you want to blit.
+/* Blits a string to a surface */
+/* Destination: the suface you want to blit to */
+/* text: a string containing the text you want to blit. */
void PutString (SDL_Surface *Surface, int x, int y, char *text);
void PutString2(SDL_Surface *Surface, SFont_FontInfo *Font, int x, int y, char *text);
-// Returns the width of "text" in pixels
+/* Returns the width of "text" in pixels */
#ifdef MACOSX
int SFont_TextWidth(char *text);
int SFont_TextWidth2(SFont_FontInfo *Font, char *text);
@@ -64,13 +64,13 @@ int TextWidth(char *text);
int TextWidth2(SFont_FontInfo *Font, char *text);
#endif
-// Blits a string to with centered x position
+/* Blits a string to with centered x position */
void XCenteredString (SDL_Surface *Surface, int y, char *text);
void XCenteredString2(SDL_Surface *Surface, SFont_FontInfo *Font, int y, char *text);
-// Allows the user to enter text
-// Width: What is the maximum width of the text (in pixels)
-// text: This string contains the text which was entered by the user
+/* Allows the user to enter text */
+/* Width: What is the maximum width of the text (in pixels) */
+/* text: This string contains the text which was entered by the user */
void SFont_Input ( SDL_Surface *Destination, int x, int y, int Width, char *text);
void SFont_Input2( SDL_Surface *Destination, SFont_FontInfo *Font, int x, int y, int Width, char *text);
Oops, something went wrong.

0 comments on commit 1d3bd3c

Please sign in to comment.