[Tux4kids-commits] r1316 - in branches/commonification/tux4kids-common/trunk: . cmake-modules src

Bolesław Kulbabiński bolekk-guest at alioth.debian.org
Fri Jul 31 23:00:26 UTC 2009


Author: bolekk-guest
Date: 2009-07-31 23:00:26 +0000 (Fri, 31 Jul 2009)
New Revision: 1316

Added:
   branches/commonification/tux4kids-common/trunk/cmake-modules/
   branches/commonification/tux4kids-common/trunk/cmake-modules/FindSDL_Pango.cmake
Modified:
   branches/commonification/tux4kids-common/trunk/CMakeLists.txt
   branches/commonification/tux4kids-common/trunk/src/CMakeLists.txt
   branches/commonification/tux4kids-common/trunk/src/t4k-sdl.c
Log:
added cmake check for SDL_Pango

Modified: branches/commonification/tux4kids-common/trunk/CMakeLists.txt
===================================================================
--- branches/commonification/tux4kids-common/trunk/CMakeLists.txt	2009-07-31 22:36:16 UTC (rev 1315)
+++ branches/commonification/tux4kids-common/trunk/CMakeLists.txt	2009-07-31 23:00:26 UTC (rev 1316)
@@ -2,6 +2,10 @@
 #other CMakeLists.txt and is not safe for human consumption. 
 #Please hack responsibly.
 
+project(Tux4Kids-common)
+
+set(CMAKE_MODULE_PATH "${Tux4Kids-common_SOURCE_DIR}/cmake-modules")
+
 cmake_minimum_required(VERSION 2.6)
 find_package(SDL REQUIRED)
 find_package(SDL_image REQUIRED)

Added: branches/commonification/tux4kids-common/trunk/cmake-modules/FindSDL_Pango.cmake
===================================================================
--- branches/commonification/tux4kids-common/trunk/cmake-modules/FindSDL_Pango.cmake	                        (rev 0)
+++ branches/commonification/tux4kids-common/trunk/cmake-modules/FindSDL_Pango.cmake	2009-07-31 23:00:26 UTC (rev 1316)
@@ -0,0 +1,83 @@
+# - Locate SDL_Pango library
+# This module defines
+#  SDLPANGO_LIBRARY, the library to link against
+#  SDLPANGO_FOUND, if false, do not try to link to SDL
+#  SDLPANGO_INCLUDE_DIR, where to find SDL/SDL.h
+#   
+# $SDLDIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDLDIR
+# used in building SDL.
+# Created by Tim Holy. This was influenced by the FindSDL_ttf.cmake
+# module by Eric Wing.
+# An SDL_Pango framework doesn't seem to exist for OS X, so the rest
+# of the comments below are probably not relevant.
+# This has modifications to recognize OS X frameworks and 
+# additional Unix paths (FreeBSD, etc).
+# On OSX, this will prefer the Framework version (if found) over others.
+# People will have to manually change the cache values of 
+# SDLPANGO_LIBRARY to override this selection.
+FIND_PATH(SDLPANGO_INCLUDE_DIR SDL_Pango.h
+  $ENV{SDLPANGODIR}/include
+  $ENV{SDLDIR}/include
+  ~/Library/Frameworks/SDL_Pango.framework/Headers
+  /Library/Frameworks/SDL_Pango.framework/Headers
+  /usr/local/include/SDL
+  /usr/include/SDL
+  /usr/local/include/SDL12
+  /usr/local/include/SDL11 # FreeBSD ports
+  /usr/include/SDL12
+  /usr/include/SDL11
+  /usr/local/include
+  /usr/include
+  /sw/include/SDL # Fink
+  /sw/include
+  /opt/local/include/SDL # DarwinPorts
+  /opt/local/include
+  /opt/csw/include/SDL # Blastwave
+  /opt/csw/include 
+  /opt/include/SDL
+  /opt/include
+  )
+# I'm not sure if I should do a special casing for Apple. It is 
+# unlikely that other Unix systems will find the framework path.
+# But if they do ([Next|Open|GNU]Step?), 
+# do they want the -framework option also?
+IF(${SDLPANGO_INCLUDE_DIR} MATCHES ".framework")
+  # Extract the path the framework resides in so we can use it for the -F flag
+  STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" SDLPANGO_FRAMEWORK_PATH_TEMP ${SDLPANGO_INCLUDE_DIR})
+  IF("${SDLPANGO_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
+      OR "${SDLPANGO_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is in default search path, don't need to use -F
+    SET(SDLPANGO_LIBRARY "-framework SDL_Pango" CACHE STRING "SDL_Pango framework for OSX")
+  ELSE("${SDLPANGO_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
+      OR "${SDLPANGO_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is not /Library/Frameworks, need to use -F
+    SET(SDLPANGO_LIBRARY "-F${SDLPANGO_FRAMEWORK_PATH_TEMP} -framework SDL_Pango" CACHE STRING "SDL_Pango framework for OSX")
+  ENDIF("${SDLPANGO_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
+    OR "${SDLPANGO_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
+    )
+  # Clear the temp variable so nobody can see it
+  SET(SDLPANGO_FRAMEWORK_PATH_TEMP "" CACHE INTERNAL "")
+
+ELSE(${SDLPANGO_INCLUDE_DIR} MATCHES ".framework")
+  FIND_LIBRARY(SDLPANGO_LIBRARY 
+    NAMES SDL_Pango
+    PATHS
+    $ENV{SDLPANGODIR}/lib
+    $ENV{SDLDIR}/lib
+    /usr/local/lib
+    /usr/lib
+    /sw/lib
+    /opt/local/lib
+    /opt/csw/lib
+    /opt/lib
+    )
+ENDIF(${SDLPANGO_INCLUDE_DIR} MATCHES ".framework")
+
+SET(SDLPANGO_FOUND "NO")
+IF(SDLPANGO_LIBRARY)
+  SET(SDLPANGO_FOUND "YES")
+ENDIF(SDLPANGO_LIBRARY)
+

Modified: branches/commonification/tux4kids-common/trunk/src/CMakeLists.txt
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/CMakeLists.txt	2009-07-31 22:36:16 UTC (rev 1315)
+++ branches/commonification/tux4kids-common/trunk/src/CMakeLists.txt	2009-07-31 23:00:26 UTC (rev 1316)
@@ -5,9 +5,10 @@
 cmake_minimum_required(VERSION 2.6)
 
 find_library(SDL REQUIRED)
+find_package(SDL_Pango)
+
 include_directories( ${SDL_INCLUDE_DIR} )
 
-
 set( T4KCOMMON_SOURCE_DIR . )
 set( TUXMATH_DESTINATION_DIR ${CMAKE_SOURCE_DIR}/../../tuxmath/trunk/ )
 set( TUXTYPE_DESTINATION_DIR ${CMAKE_SOURCE_DIR}/../../tuxtype/trunk/ )
@@ -35,11 +36,16 @@
   set(_rsvg_def "-DHAVE_RSVG=1")
 endif(HAVE_RSVG)
 
+set(_pango_def "")
+if (SDLPANGO_FOUND)
+  set(_pango_def "-DHAVE_LIBSDL_PANGO=1")
+endif (SDLPANGO_FOUND)
 
+
 set_target_properties (
   t4kcommon
   PROPERTIES COMPILE_FLAGS
-  "${_rsvg_def} ${_rsvg_cflags} ${_cairo_cflags}"
+  "${_rsvg_def} ${_pango_def} ${_rsvg_cflags} ${_cairo_cflags}"
   )
 
 

Modified: branches/commonification/tux4kids-common/trunk/src/t4k-sdl.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-sdl.c	2009-07-31 22:36:16 UTC (rev 1315)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-sdl.c	2009-07-31 23:00:26 UTC (rev 1316)
@@ -17,6 +17,13 @@
 
 static SDL_Surface* screen = NULL;
 
+char* font_name;
+
+void SetFontName(char* fname)
+{
+  font_name = fname;
+}
+
 /*
 Return a pointer to the screen we're using, as an alternative to making screen
 global. Not sure what is involved performance-wise in SDL_GetVideoSurface,
@@ -677,6 +684,7 @@
 /************************************************************************/
 
 #define MAX_FONT_SIZE 40
+#define DEFAULT_FONT_SIZE 10
 
 //NOTE to test program with SDL_ttf, do "./configure --without-sdlpango"
 
@@ -712,7 +720,7 @@
   DEBUGMSG(dbg_sdl, "Setup_SDL_Text() - using SDL_Pango\n");
 
   SDLPango_Init();
-  if (!Set_SDL_Pango_Font_Size(DEFAULT_MENU_FONT_SIZE))
+  if (!Set_SDL_Pango_Font_Size(DEFAULT_FONT_SIZE))
   {
     fprintf(stderr, "\nError: I could not set SDL_Pango context\n");
     return 0;
@@ -992,7 +1000,7 @@
   /* Do nothing unless we need to change size or font: */
   if ((size == prev_pango_font_size)
       &&
-      (0 == strncmp(prev_font_name, Opts_FontName(), sizeof(prev_font_name))))
+      (0 == strncmp(prev_font_name, font_name, sizeof(prev_font_name))))
     return 1;
   else
   {
@@ -1003,7 +1011,7 @@
     if(context != NULL)
       SDLPango_FreeContext(context);
     context = NULL;
-    snprintf(buf, sizeof(buf), "%s %d", Opts_FontName(), (int)((size * 3)/4));
+    snprintf(buf, sizeof(buf), "%s %d", font_name, (int)((size * 3)/4));
     context =  SDLPango_CreateContext_GivenFontDesc(buf);
   }
 
@@ -1012,7 +1020,7 @@
   else
   {
     prev_pango_font_size = size;
-    strncpy(prev_font_name, Opts_FontName(), sizeof(prev_font_name));
+    strncpy(prev_font_name, font_name, sizeof(prev_font_name));
     return 1;
   }
 }
@@ -1061,7 +1069,6 @@
   }
 }
 
-#if 0
 /* FIXME - could combine this with load_font() below:         */
 /* Loads and caches fonts in each size as they are requested: */
 /* We use the font size as an array index, keeping each size  */
@@ -1083,10 +1090,10 @@
   }
 
   /* If the font has changed, we need to wipe out the old ones: */
-  if (0 != strncmp(prev_font_name, Opts_FontName(),sizeof(prev_font_name)))
+  if (0 != strncmp(prev_font_name, font_name, sizeof(prev_font_name)))
   {
     free_font_list();
-    strncpy(prev_font_name, Opts_FontName(), sizeof(prev_font_name));
+    strncpy(prev_font_name, font_name, sizeof(prev_font_name));
   }
 
   if(font_list[size] == NULL)
@@ -1127,4 +1134,3 @@
   }
 }
 #endif
-#endif




More information about the Tux4kids-commits mailing list