r3707 - in packages/trunk/hex-a-hop/debian: . patches
Jens Seidel
jseidel-guest at alioth.debian.org
Sat Aug 18 22:49:52 UTC 2007
Author: jseidel-guest
Date: 2007-08-18 22:49:52 +0000 (Sat, 18 Aug 2007)
New Revision: 3707
Modified:
packages/trunk/hex-a-hop/debian/changelog
packages/trunk/hex-a-hop/debian/patches/compiler_warnings.patch
packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch
Log:
* Use new font also for help dialog title, required for
Vietnamese.
Modified: packages/trunk/hex-a-hop/debian/changelog
===================================================================
--- packages/trunk/hex-a-hop/debian/changelog 2007-08-18 20:58:02 UTC (rev 3706)
+++ packages/trunk/hex-a-hop/debian/changelog 2007-08-18 22:49:52 UTC (rev 3707)
@@ -5,6 +5,8 @@
<clytie at riverland.net.au>. Closes: #438453
* Added (incomplete) Russian translation. Thanks to Yuri
Kozlov <kozlov.y at gmail.com>. Closes: #438644
+ * Use new font also for help dialog title, required for
+ Vietnamese.
-- Jens Seidel <jensseidel at users.sf.net> Sat, 18 Aug 2007 19:40:41 +0200
Modified: packages/trunk/hex-a-hop/debian/patches/compiler_warnings.patch
===================================================================
--- packages/trunk/hex-a-hop/debian/patches/compiler_warnings.patch 2007-08-18 20:58:02 UTC (rev 3706)
+++ packages/trunk/hex-a-hop/debian/patches/compiler_warnings.patch 2007-08-18 22:49:52 UTC (rev 3707)
@@ -203,7 +203,7 @@
struct RenderStage
{
-+ virtual ~RenderStage() {}
++ virtual ~RenderStage() {}
virtual void Render(RenderObject* r, double time, bool reflect) = 0;
- virtual int GetDepth(double time) { return 1; }
+ virtual int GetDepth(double /*time*/) { return 1; }
Modified: packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch
===================================================================
--- packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch 2007-08-18 20:58:02 UTC (rev 3706)
+++ packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch 2007-08-18 22:49:52 UTC (rev 3707)
@@ -1,8 +1,16 @@
Index: hex-a-hop.svn/gfx.cpp
===================================================================
---- hex-a-hop.svn.orig/gfx.cpp 2007-08-15 12:55:15.000000000 +0200
-+++ hex-a-hop.svn/gfx.cpp 2007-08-15 12:55:16.000000000 +0200
-@@ -30,6 +30,14 @@
+--- hex-a-hop.svn.orig/gfx.cpp 2007-08-19 00:25:43.000000000 +0200
++++ hex-a-hop.svn/gfx.cpp 2007-08-19 00:26:59.000000000 +0200
+@@ -19,6 +19,7 @@
+ #include "i18n.h"
+
+ #include "state.h"
++#include <cassert>
+
+ #ifdef WIN32
+ #include <SDL_syswm.h>
+@@ -30,6 +31,14 @@
#undef USE_BBTABLET
#endif
@@ -17,7 +25,7 @@
#ifndef DATA_DIR
#define DATA_DIR "."
#endif
-@@ -110,6 +118,7 @@
+@@ -110,6 +119,7 @@
float styluspressure = 0;
SDL_Surface * screen = 0;
SDL_Surface * realScreen = 0;
@@ -25,10 +33,38 @@
extern State* MakeWorld();
-@@ -157,6 +166,50 @@
+@@ -157,6 +167,66 @@
}
String base_path;
++/// determine length of longest line with current font (no wrapping)
++int SDLPangoTextWidth(const std::string &text_utf8)
++{
++ int max_width = 0;
++ SDLPango_SetMinimumSize(context, -1, 0); // -1: no wrap
++ 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(context, line.c_str(), -1);
++ max_width = std::max(max_width, SDLPango_GetLayoutWidth(context));
++ }
++ return max_width;
++}
++
++/// Display the specified UTF-8 text left aligned at (x,y)
++void Print_Pango(int x, int y, const std::string &text_utf8)
++{
++ assert(text_utf8.find("\n") == std::string::npos);
++ SDLPango_SetText(context, text_utf8.c_str(), -1);
++ SDL_Surface *surface = SDLPango_CreateSurfaceDraw(context);
++ SDL_Rect dst = {x, y, 1, 1};
++ SDL_BlitSurface(surface, NULL, screen, &dst);
++ SDL_FreeSurface(surface);
++}
++
+/** \brief Display the specified UTF-8 text horizontally centered around (x,y)
+ *
+ * We wrap (as workaround) only for translations as the English
@@ -41,64 +77,61 @@
+ * */
+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;
++ 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);
++ int max_width = 0;
++ if (!automatically_wrap_text)
++ max_width = SDLPangoTextWidth(text_utf8);
+
-+ // 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);
++ // 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, 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 @@
+@@ -204,6 +274,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);
++ 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 @@
+@@ -378,7 +452,7 @@
+ if (!td.isValid())
+ printf("No tablet/driver found\n");
+ #endif
+- }
++ }
+ if (m->msg == WM_DROPFILES)
+ {
+ HDROP h = (HDROP)m->wParam;
+@@ -476,6 +550,7 @@
}
}
-+ SDLPango_FreeContext(context);
++ 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 12:55:15.000000000 +0200
-+++ hex-a-hop.svn/hex_puzzzle.cpp 2007-08-15 13:37:36.000000000 +0200
+--- hex-a-hop.svn.orig/hex_puzzzle.cpp 2007-08-19 00:25:43.000000000 +0200
++++ hex-a-hop.svn/hex_puzzzle.cpp 2007-08-19 00:27:53.000000000 +0200
@@ -17,6 +17,10 @@
*/
@@ -110,15 +143,46 @@
//////////////////////////////////////////////////////
// Config
-@@ -406,6 +410,7 @@
+@@ -406,15 +410,36 @@
}
}
-+/// Prints a left aligned string beginning at (x,y)
++void ConvertToUTF8(const std::string &text_locally_encoded, char *text_utf8, size_t text_utf8_length)
++{
++ // Is this portable?
++ size_t text_length = text_locally_encoded.length()+1;
++ errno = 0;
++ static const char *locale_enc = gettext_init.GetEncoding();
++ iconv_t cd = iconv_open("UTF-8", locale_enc);
++ char *in_buf = const_cast<char *>(&text_locally_encoded[0]);
++ char *out_buf = &text_utf8[0];
++ iconv(cd, &in_buf, &text_length, &out_buf, &text_utf8_length);
++ iconv_close(cd);
++ if (errno != 0)
++ std::cerr << "An error occurred recoding " << text_locally_encoded << " to UTF8" << std::endl;
++}
++
++int SDLPangoTextWidth(const std::string &text_utf8);
++void Print_Pango(int x, int y, const std::string &text_utf8);
++void PrintC_Pango(int x, int y, const std::string &text_utf8);
++
++/// Prints a left aligned string (a single line) beginning at (x,y)
void Print(int x, int y, const char * string, ...)
{
va_list marker;
-@@ -427,6 +432,7 @@
+ va_start( marker, string ); /* Initialize variable arguments. */
+
+- char tmp[1000];
++ char tmp[1000], tmp_utf8[5000]; // FIXME: Check this limit
+ vsprintf((char*)tmp, string, marker);
+
+- PrintRaw(x, y, tmp);
++ ConvertToUTF8(tmp, tmp_utf8, sizeof(tmp_utf8)/sizeof(char));
++ Print_Pango(x, y, tmp_utf8);
+
+ va_end( marker ); /* Reset variable arguments. */
+ }
+@@ -427,29 +452,44 @@
return w;
}
@@ -126,11 +190,19 @@
void PrintR(int x, int y, const char * string, ...)
{
va_list marker;
-@@ -440,16 +446,39 @@
+ va_start( marker, string ); /* Initialize variable arguments. */
+
+- char tmp[1000];
++ char tmp[1000], tmp_utf8[5000]; // FIXME: Check this limit
+ vsprintf((char*)tmp, string, marker);
+
+- PrintRaw(x-FontWidth(tmp), y, tmp);
++ ConvertToUTF8(tmp, tmp_utf8, sizeof(tmp_utf8)/sizeof(char));
++ Print_Pango(x-SDLPangoTextWidth(tmp_utf8), y, tmp_utf8);
+
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
@@ -146,30 +218,21 @@
- char* scan = tmp;
- while (1)
-+ // Is this portable?
-+ size_t tmp_length = std::string(tmp).length()+1, tmp_utf8_length = 5000;
-+ errno = 0;
-+ static const char *locale_enc = gettext_init.GetEncoding();
-+ iconv_t cd = iconv_open("UTF-8", locale_enc);
-+ char *in_buf = &tmp[0], *out_buf = &tmp_utf8[0];
-+ iconv(cd, &in_buf, &tmp_length, &out_buf, &tmp_utf8_length);
-+ iconv_close(cd);
-+ if (errno != 0)
-+ std::cerr << "An error occurred recoding " << tmp << " to UTF8" << std::endl;
++ ConvertToUTF8(tmp, tmp_utf8, sizeof(tmp_utf8)/sizeof(char));
+
-+ if (std::string(_("Press any key")) != std::string("Press any key"))
-+ split = false; // TODO: Let's ignore linebreaks in translations for now
++ 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");
++ 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);
++ PrintC_Pango(x, y, msg);
+ /*
{
char * end = split ? strstr(scan," ") : 0;
if (!end)
-@@ -465,6 +494,7 @@
+@@ -465,6 +505,7 @@
y += FONT_SPACING;
}
}
More information about the Pkg-games-commits
mailing list