[Tux4kids-commits] r477 - in tuxmath/trunk: . src

tholy-guest at alioth.debian.org tholy-guest at alioth.debian.org
Mon May 5 10:45:43 UTC 2008


Author: tholy-guest
Date: 2008-05-05 10:45:42 +0000 (Mon, 05 May 2008)
New Revision: 477

Modified:
   tuxmath/trunk/config.h.in
   tuxmath/trunk/configure.ac
   tuxmath/trunk/src/SDL_extras.c
   tuxmath/trunk/src/setup.c
Log:
Check in Ahmed's patch to support SDL-Pango.  This is configured with configure --enable-sdlpango.


Modified: tuxmath/trunk/config.h.in
===================================================================
--- tuxmath/trunk/config.h.in	2008-05-01 21:11:06 UTC (rev 476)
+++ tuxmath/trunk/config.h.in	2008-05-05 10:45:42 UTC (rev 477)
@@ -391,6 +391,9 @@
 /* Define if the pthread_in_use() detection is hard. */
 #undef PTHREAD_IN_USE_DETECTION_HARD
 
+/* Defined when SDL_Pango support is present and compiled */
+#undef SDL_Pango
+
 /* Define as the maximum value of type 'size_t', if the system doesn't define
    it. */
 #undef SIZE_MAX

Modified: tuxmath/trunk/configure.ac
===================================================================
--- tuxmath/trunk/configure.ac	2008-05-01 21:11:06 UTC (rev 476)
+++ tuxmath/trunk/configure.ac	2008-05-05 10:45:42 UTC (rev 477)
@@ -97,6 +97,15 @@
 )
 
 
+dnl sdlpango support
+have_sdlpango=no
+AC_ARG_ENABLE(sdlpango, [  --enable-sdlpango    Enable SDL_Pango (default is  disabled)],have_sdlpango=yes)
+if test $have_sdlpango = "yes"; then
+	AC_CHECK_LIB([SDL_Pango],[SDLPango_Init],LIBS="$LIBS -lSDL_Pango",have_sdlpango=no)
+fi
+if test "$have_sdlpango" = "yes"; then
+	AC_DEFINE([SDL_Pango],[],[Defined when SDL_Pango support is present and compiled])
+fi
 
 
 # --------------------------------------------------------------------------------------

Modified: tuxmath/trunk/src/SDL_extras.c
===================================================================
--- tuxmath/trunk/src/SDL_extras.c	2008-05-01 21:11:06 UTC (rev 476)
+++ tuxmath/trunk/src/SDL_extras.c	2008-05-05 10:45:42 UTC (rev 477)
@@ -13,7 +13,11 @@
 #include "SDL_extras.h"
 #include "tuxmath.h"
 
+#ifdef SDL_Pango
+#include "SDL_Pango.h"
+#endif
 
+
 /* DrawButton() creates and draws a translucent button with */
 /* rounded ends.  All colors and alpha values are supported.*/
 void DrawButton(SDL_Rect* target_rect,
@@ -314,7 +318,19 @@
   return ret;
 }
 
-
+#ifdef SDL_Pango
+SDLPango_Context *context = NULL;
+void init_SDLPango_Context()
+{
+   context =  SDLPango_CreateContext_GivenFontDesc(DEFAULT_FONT_NAME);
+}  
+void free_SDLPango_Context() 
+{
+  if(context != NULL)
+    SDLPango_FreeContext(context);
+  context = NULL;
+}
+#endif
 /* BlackOutline() creates a surface containing text of the designated */
 /* foreground color, surrounded by a black shadow, on a transparent    */
 /* background.  The appearance can be tuned by adjusting the number of */
@@ -340,7 +356,19 @@
   fprintf( stderr, "BlackOutline of \"%s\"\n", t );
 #endif
 
+#ifndef SDL_Pango
   black_letters = TTF_RenderUTF8_Blended(font, t, black);
+#else
+  if( context != NULL)
+  {
+    SDLPango_SetDefaultColor(context, MATRIX_TRANSPARENT_BACK_BLACK_LETTER);
+    SDLPango_SetText(context, t, -1);
+    black_letters = SDLPango_CreateSurfaceDraw(context);
+  }
+  else {
+    black_letters = TTF_RenderUTF8_Blended(font, t, black);
+  }
+#endif
 
   if (!black_letters)
   {
@@ -370,7 +398,19 @@
   SDL_FreeSurface(black_letters);
 
   /* --- Put the color version of the text on top! --- */
+#ifndef SDL_Pango
   white_letters = TTF_RenderUTF8_Blended(font, t, *c);
+#else
+  if( context != NULL)
+  {
+    SDLPango_SetDefaultColor(context, MATRIX_TRANSPARENT_BACK_WHITE_LETTER);
+    white_letters = SDLPango_CreateSurfaceDraw(context);
+  }
+  else {
+    white_letters = TTF_RenderUTF8_Blended(font, t, *c);
+  }
+#endif
+
   dstrect.x = 1;
   dstrect.y = 1;
   SDL_BlitSurface(white_letters, NULL, bg, &dstrect);

Modified: tuxmath/trunk/src/setup.c
===================================================================
--- tuxmath/trunk/src/setup.c	2008-05-01 21:11:06 UTC (rev 476)
+++ tuxmath/trunk/src/setup.c	2008-05-05 10:45:42 UTC (rev 477)
@@ -439,6 +439,17 @@
 
   atexit(TTF_Quit); // Maybe this is redundant?
 
+#ifdef SDL_Pango
+  if (SDLPango_Init () < 0)
+  {
+      fprintf(stderr,
+            "\nWarning: I could not initialize SDL_Pango !\n"
+            "%s\n\n", SDL_GetError());
+  }
+  else {
+    init_SDLPango_Context();
+  }
+#endif
 
 
   #ifndef NOSOUND
@@ -701,7 +712,12 @@
     Mix_CloseAudio();
     n_timesopened--;
   }
+  
+#ifdef SDL_Pango
+   free_SDLPango_Context();
+#endif
 
+
   // Finally, quit SDL
   SDL_Quit();
 




More information about the Tux4kids-commits mailing list