r3687 - in packages/trunk/hex-a-hop/debian: . patches

Jens Seidel jseidel-guest at alioth.debian.org
Wed Aug 15 02:38:33 UTC 2007


Author: jseidel-guest
Date: 2007-08-15 02:38:33 +0000 (Wed, 15 Aug 2007)
New Revision: 3687

Added:
   packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch
Modified:
   packages/trunk/hex-a-hop/debian/changelog
   packages/trunk/hex-a-hop/debian/control
   packages/trunk/hex-a-hop/debian/patches/series
Log:
* Use the SDLPango library for font handling. This is a first
  draft and behaves differently for English and translations. It
  also assumes a UTF-8 locale. It partely addresses #436469.


Modified: packages/trunk/hex-a-hop/debian/changelog
===================================================================
--- packages/trunk/hex-a-hop/debian/changelog	2007-08-15 00:43:44 UTC (rev 3686)
+++ packages/trunk/hex-a-hop/debian/changelog	2007-08-15 02:38:33 UTC (rev 3687)
@@ -15,6 +15,9 @@
     <debian at helgefjell.de>. Closes: #437440, #437439
   * Fixed all compiler warnings and use e.g. -Wall -Wextra
     default. Closes: #437313
+  * Use the SDLPango library for font handling. This is a first
+    draft and behaves differently for English and translations. It
+    also assumes a UTF-8 locale. It partely addresses #436469.
 
  -- Miriam Ruiz <little_miry at yahoo.es>  Wed,  8 Aug 2007 16:34:41 +0200
 

Modified: packages/trunk/hex-a-hop/debian/control
===================================================================
--- packages/trunk/hex-a-hop/debian/control	2007-08-15 00:43:44 UTC (rev 3686)
+++ packages/trunk/hex-a-hop/debian/control	2007-08-15 02:38:33 UTC (rev 3687)
@@ -3,7 +3,7 @@
 Priority: extra
 Maintainer: Debian Games Team <pkg-games-devel at lists.alioth.debian.org> 
 Uploaders: Miriam Ruiz <little_miry at yahoo.es>, Sam Hocevar (Debian packages) <sam+deb at zoy.org>
-Build-Depends: debhelper (>= 5), quilt, gettext, libsdl1.2-dev
+Build-Depends: debhelper (>= 5), quilt, gettext, libsdl1.2-dev, libsdl-pango-dev
 Standards-Version: 3.7.2
 XS-Vcs-Svn: svn://svn.debian.org/svn/pkg-games/packages/trunk/hex-a-hop/
 XS-Vcs-Browser: http://svn.debian.org/wsvn/pkg-games/packages/trunk/hex-a-hop/?op=log

Added: packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch
===================================================================
--- packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch	                        (rev 0)
+++ packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch	2007-08-15 02:38:33 UTC (rev 3687)
@@ -0,0 +1,182 @@
+Index: hex-a-hop.svn/gfx.cpp
+===================================================================
+--- hex-a-hop.svn.orig/gfx.cpp	2007-08-15 03:04:57.000000000 +0200
++++ hex-a-hop.svn/gfx.cpp	2007-08-15 04:41:18.000000000 +0200
+@@ -30,6 +30,14 @@
+ 	#undef USE_BBTABLET
+ #endif
+ 
++// If included multiple times:
++// BUG: multiple definition of `MATRIX_WHITE_BACK'
++// see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=437517
++#include "SDL_Pango.h"
++
++#include <algorithm>
++#include <string>
++
+ #ifndef DATA_DIR
+ #define DATA_DIR "."
+ #endif
+@@ -110,6 +118,7 @@
+ float styluspressure = 0;
+ SDL_Surface * screen = 0;
+ SDL_Surface * realScreen = 0;
++SDLPango_Context *context = 0;
+ 
+ extern State* MakeWorld();
+ 
+@@ -157,6 +166,50 @@
+ }
+ String base_path;
+ 
++/** \brief Display the specified UTF-8 text horizontally centered around (x,y)
++ *
++ *  We wrap (as workaround) only for translations as the English
++ *  texts contain already properly added (fixed, but independent of font!)
++ *  linebreaks. Problem: If we try to wrap ourself, what's the maximal
++ *  text size? We just assume a small border (10) on each? side and assume
++ *  the background text window is suffient large.
++ *
++ *  TODO: Wrap all text and specify the background window size.
++ * */
++void PrintC_Pango(int x, int y, const std::string &text_utf8)
++{
++  bool automatically_wrap_text = true;
++  if (std::string(_("Press any key")) == std::string("Press any key"))
++    // let's wrap text for translations only (English is properly balanced)
++    automatically_wrap_text = false;
++
++  int max_width = 0;
++  if (!automatically_wrap_text) {
++    SDLPango_SetMinimumSize(context, -1, 0);
++
++    // determine longest line with current font
++    std::string::size_type next_newline_pos = 0;
++    while (next_newline_pos != std::string::npos) {
++      std::string::size_type line_start = next_newline_pos;
++      next_newline_pos = text_utf8.find("\n", next_newline_pos+1);
++      std::string line = text_utf8.substr(line_start,
++          next_newline_pos == std::string::npos ? std::string::npos : next_newline_pos-line_start);
++      // SDLPango_SetText_GivenAlignment is not (yet?) part of the official Pango
++      // distribution, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=437865
++      SDLPango_SetText_GivenAlignment(context, line.c_str(), -1, SDLPANGO_ALIGN_CENTER);
++      max_width = std::max(max_width, SDLPango_GetLayoutWidth(context));
++    }
++  }
++
++  SDLPango_SetText_GivenAlignment(context, text_utf8.c_str(), -1, SDLPANGO_ALIGN_CENTER);
++  SDL_Surface *surface = SDLPango_CreateSurfaceDraw(context);
++  // TODO: 10 is wrong (the size of the background window is unknown!);
++  // we start nearly at the left side of the screen for translations
++  SDL_Rect dst = {automatically_wrap_text ? 10 : x-max_width/2, y, 1, 1};
++  SDL_BlitSurface(surface, NULL, screen, &dst);
++  SDL_FreeSurface(surface);
++}
++
+ int TickTimer()
+ {
+ 	static int time = SDL_GetTicks();
+@@ -204,6 +257,10 @@
+ */
+ 
+ 	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
++  SDLPango_Init();
++  context = SDLPango_CreateContext();
++  SDLPango_SetDefaultColor(context, MATRIX_TRANSPARENT_BACK_WHITE_LETTER);
++  SDLPango_SetMinimumSize(context, SCREEN_W, 0);
+ 
+ 	SDL_Surface* icon = SDL_LoadBMP("graphics/icon.bmp");
+ 	if (icon)
+@@ -476,6 +533,7 @@
+ 		}
+ 	}
+ 
++  SDLPango_FreeContext(context);
+ 	SDL_Quit();
+ 	return 0;
+ }
+Index: hex-a-hop.svn/hex_puzzzle.cpp
+===================================================================
+--- hex-a-hop.svn.orig/hex_puzzzle.cpp	2007-08-15 03:01:37.000000000 +0200
++++ hex-a-hop.svn/hex_puzzzle.cpp	2007-08-15 04:32:43.000000000 +0200
+@@ -17,6 +17,7 @@
+ */
+ 
+ #include "i18n.h"
++#include <string>
+ 
+ //////////////////////////////////////////////////////
+ // Config
+@@ -406,6 +407,7 @@
+ 	}
+ }
+ 
++/// Prints a left aligned string beginning at (x,y)
+ void Print(int x, int y, const char * string, ...)
+ {
+ 	va_list marker;
+@@ -427,6 +429,7 @@
+ 	return w;
+ }
+ 
++/// Prints a string right aligned so that it ends at (x,y)
+ void PrintR(int x, int y, const char * string, ...)
+ {
+ 	va_list marker;
+@@ -440,16 +443,32 @@
+ 	va_end( marker );              /* Reset variable arguments.      */
+ }
+ 
++void PrintC_Pango(int x, int y, const std::string &text_utf8);
++/** \brief Prints a string horizontally centered around (x,y)
++ *
++ *  "  " in the string is interpreted as linebreak
++*/
+ void PrintC(bool split, int x, int y, const char * string, ...)
+ {
+ 	va_list marker;
+ 	va_start( marker, string );     /* Initialize variable arguments. */
+ 
+-	char tmp[1000];
++	char tmp[1000]; // FIXME: Check this limit
+ 	vsprintf((char*)tmp, string, marker);
+ 
+-	char* scan = tmp;
+-	while (1)
++  const char *tmp_utf8 = tmp;
++  // TODO: convert tmp (from current locale encoding) to UTF-8
++  // How? using iconv? Is this portable?
++
++  if (std::string(_("Press any key")) != std::string("Press any key"))
++    split = false; // TODO: Let's ignore linebreaks in translations for now
++
++  std::string msg(tmp_utf8);
++  while (split && msg.find("  ") != std::string::npos)
++    msg.replace(msg.find("  "), std::string("\n").length(), "\n");
++
++  PrintC_Pango(x, y, msg);
++  /*
+ 	{
+ 		char * end = split ? strstr(scan,"  ") : 0;
+ 		if (!end)
+@@ -465,6 +484,7 @@
+ 			y += FONT_SPACING;
+ 		}
+ 	}
++  */
+ 
+ 	va_end( marker );              /* Reset variable arguments.      */
+ }
+Index: hex-a-hop.svn/Makefile
+===================================================================
+--- hex-a-hop.svn.orig/Makefile	2007-08-15 03:13:30.000000000 +0200
++++ hex-a-hop.svn/Makefile	2007-08-15 03:13:47.000000000 +0200
+@@ -19,7 +19,7 @@
+ 	$(GCC) $(CXXFLAGS) -D_VERSION=\"$(VERSION)\" -DDATA_DIR=\"$(DATA_DIR)\" `sdl-config --cflags`  -c -o $@ $<
+ 	
+ $(NAME) : $(OBJS)
+-		$(GCC) $(CXXFLAGS) $(OBJS)  `sdl-config --libs` -lm  \
++		$(GCC) $(CXXFLAGS) $(OBJS)  `sdl-config --libs` -lSDL_Pango -lm  \
+ 		-o $(NAME)
+ 
+ clean :

Modified: packages/trunk/hex-a-hop/debian/patches/series
===================================================================
--- packages/trunk/hex-a-hop/debian/patches/series	2007-08-15 00:43:44 UTC (rev 3686)
+++ packages/trunk/hex-a-hop/debian/patches/series	2007-08-15 02:38:33 UTC (rev 3687)
@@ -5,3 +5,4 @@
 patch-hex-a-hop-better-than-par.diff
 typos.patch
 compiler_warnings.patch
+pango_fonts.patch




More information about the Pkg-games-commits mailing list