Attempted to add a vertical nudge value for tool button labels, based

on locale.  (Specifically, to prevent Khmer text from overlapping icons.)
Locale-related code needs some bugfixing before this works right, though.
This commit is contained in:
William Kendrick 2008-02-19 20:46:03 +00:00
parent 0ae6112586
commit 24768b831b
4 changed files with 52 additions and 16 deletions

View file

@ -9,7 +9,7 @@ http://www.tuxpaint.org/
$Id$ $Id$
2008.February.17 (0.9.19) 2008.February.19 (0.9.19)
* New Localizations: * New Localizations:
------------------ ------------------
* Australian English * Australian English
@ -69,6 +69,10 @@ $Id$
* Russian translation * Russian translation
Sergei Popov <skein@rambler.ru> Sergei Popov <skein@rambler.ru>
* Attempted to add a vertical nudge value for tool button labels, based
on locale. (Specifically, to prevent Khmer text from overlapping icons.)
Locale-related code needs some bugfixing before this works right, though.
* System-Related Improvements: * System-Related Improvements:
---------------------------- ----------------------------
* Removed unfinished, unused record and playback code. * Removed unfinished, unused record and playback code.
@ -77,10 +81,12 @@ $Id$
on first launch from a non-admin account on Mac OS X. on first launch from a non-admin account on Mac OS X.
Martin Fuhrer <mfuhrer@users.sourceforge.net> Martin Fuhrer <mfuhrer@users.sourceforge.net>
* Fixed possible lockups in fullscreen mode when attempting to print on Mac OS X. * Fixed possible lockups in fullscreen mode when attempting to print on
Mac OS X.
Martin Fuhrer <mfuhrer@users.sourceforge.net> Martin Fuhrer <mfuhrer@users.sourceforge.net>
* Skipping "AppleMyungjo.ttf" when loading fonts on Mac OS X to avoid TTF lib. crash. * Skipping "AppleMyungjo.ttf" when loading fonts on Mac OS X to avoid
TTF lib. crash.
Martin Fuhrer <mfuhrer@users.sourceforge.net> Martin Fuhrer <mfuhrer@users.sourceforge.net>
* Documentation Improvements: * Documentation Improvements:

View file

@ -25,7 +25,7 @@
$Id$ $Id$
June 14, 2002 - February 17, 2008 June 14, 2002 - February 19, 2008
*/ */
#include <stdio.h> #include <stdio.h>
@ -180,6 +180,11 @@ int lang_use_right_to_left_word[] = {
-1 -1
}; };
int lang_y_nudge[][2] = {
{LANG_KM, 4},
{-1, -1}
};
char *langstr; char *langstr;
int need_own_font; int need_own_font;
@ -347,10 +352,13 @@ void ctype_utf8(void)
/* Determine the current language/locale, and set the language string: */ /* Determine the current language/locale, and set the language string: */
void set_current_language(void) int set_current_language(void)
{ {
char *loc; char *loc;
int i, found; int i, found;
int y_nudge;
y_nudge = 0;
bindtextdomain("tuxpaint", LOCALEDIR); bindtextdomain("tuxpaint", LOCALEDIR);
/* Old version of glibc does not have bind_textdomain_codeset() */ /* Old version of glibc does not have bind_textdomain_codeset() */
@ -365,11 +373,16 @@ void set_current_language(void)
#ifndef WIN32 #ifndef WIN32
loc = setlocale(LC_MESSAGES, NULL); loc = setlocale(LC_MESSAGES, NULL); // NULL: Used to direct setlocale() to query the current internationalised environment and return the name of the locale().
// FIXME: I'm getting back en_US.UTF-8 even after LC_ALL has been putenv()'d...?? -bjk 2008.02.19
if (loc != NULL) if (loc != NULL)
{ {
if (strstr(loc, "LC_MESSAGES") != NULL) if (strstr(loc, "LC_MESSAGES") != NULL)
{
loc = getenv("LANG"); loc = getenv("LANG");
}
} }
#else #else
bind_textdomain_codeset("tuxpaint", "UTF-8"); bind_textdomain_codeset("tuxpaint", "UTF-8");
@ -408,11 +421,24 @@ void set_current_language(void)
} }
} }
/* FIXME: These don't work because we have the wrong langint...!? -bjk 2008.02.19 */
lang_prefix = lang_prefixes[langint]; lang_prefix = lang_prefixes[langint];
need_own_font = search_int_array(langint, lang_use_own_font); need_own_font = search_int_array(langint, lang_use_own_font);
need_right_to_left = search_int_array(langint, lang_use_right_to_left); need_right_to_left = search_int_array(langint, lang_use_right_to_left);
need_right_to_left_word = search_int_array(langint, lang_use_right_to_left_word); need_right_to_left_word = search_int_array(langint, lang_use_right_to_left_word);
for (i = 0; lang_y_nudge[i][0] != -1; i++)
{
printf("lang_y_nudge[%d][0] = %d\n", i, lang_y_nudge[i][0]);
if (lang_y_nudge[i][0] == langint)
{
y_nudge = lang_y_nudge[i][1];
printf("y_nudge = %d\n", y_nudge);
}
}
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: Language is %s (%d) %s/%s\n", fprintf(stderr, "DEBUG: Language is %s (%d) %s/%s\n",
lang_prefix, langint, lang_prefix, langint,
@ -421,6 +447,7 @@ void set_current_language(void)
fflush(stderr); fflush(stderr);
#endif #endif
return(y_nudge);
} }
@ -615,7 +642,7 @@ void show_locale_usage(FILE * f, const char *const prg)
"\n", prg); "\n", prg);
} }
void setup_language(const char *const prg) void setup_language(const char *const prg, int * y_nudge)
{ {
// Justify this or delete it. It seems to make Tux Paint // Justify this or delete it. It seems to make Tux Paint
@ -676,13 +703,14 @@ void setup_language(const char *const prg)
putenv(s); putenv(s);
} }
setlocale(LC_ALL, ""); setlocale(LC_ALL, ""); // Specifies an implementation-dependent native environment. For XSI-conformant systems, this corresponds to the value of the associated environment variables, LC_* and LANG
ctype_utf8(); ctype_utf8();
free(langstr); free(langstr);
langstr = NULL; langstr = NULL;
} }
set_current_language(); *y_nudge = set_current_language();
} }

View file

@ -10,7 +10,7 @@
$Id$ $Id$
June 14, 2002 - February 17, 2008 June 14, 2002 - February 18, 2008
*/ */
@ -135,11 +135,11 @@ extern const language_to_locale_struct language_to_locale_array[];
/* Function prototypes: */ /* Function prototypes: */
void set_langstr(const char *s); void set_langstr(const char *s);
void set_current_language(void); int set_current_language(void);
int get_current_language(void); int get_current_language(void);
void show_lang_usage(FILE * f, const char *const prg); void show_lang_usage(FILE * f, const char *const prg);
void show_locale_usage(FILE * f, const char *const prg); void show_locale_usage(FILE * f, const char *const prg);
void setup_language(const char *const prg); void setup_language(const char *const prg, int * y_nudge);
void do_locale_option(const char *const arg); void do_locale_option(const char *const arg);
void ctype_utf8(void); void ctype_utf8(void);

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - December 31, 2007 June 14, 2002 - February 18, 2008
$Id$ $Id$
*/ */
@ -961,6 +961,8 @@ static SDL_Surface *img_title_on, *img_title_off,
static SDL_Surface *img_title_names[NUM_TITLES]; static SDL_Surface *img_title_names[NUM_TITLES];
static SDL_Surface *img_tools[NUM_TOOLS], *img_tool_names[NUM_TOOLS]; static SDL_Surface *img_tools[NUM_TOOLS], *img_tool_names[NUM_TOOLS];
static int button_label_y_nudge;
static SDL_Surface *thumbnail(SDL_Surface * src, int max_x, int max_y, static SDL_Surface *thumbnail(SDL_Surface * src, int max_x, int max_y,
int keep_aspect); int keep_aspect);
static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y,
@ -6709,7 +6711,7 @@ static void setup(int argc, char *argv[])
} }
setup_language(getfilename(argv[0])); setup_language(getfilename(argv[0]), &button_label_y_nudge);
im_init(&im_data, get_current_language()); im_init(&im_data, get_current_language());
#ifndef NO_SDLPANGO #ifndef NO_SDLPANGO
@ -7771,7 +7773,7 @@ static SDL_Surface *do_render_button_label(const char *const label)
myfont = locale_font; myfont = locale_font;
tmp_surf = render_text(myfont, upstr, black); tmp_surf = render_text(myfont, upstr, black);
free(upstr); free(upstr);
surf = thumbnail(tmp_surf, min(48, tmp_surf->w), tmp_surf->h, 0); surf = thumbnail(tmp_surf, min(48, tmp_surf->w), min(18 + button_label_y_nudge, tmp_surf->h), 0);
SDL_FreeSurface(tmp_surf); SDL_FreeSurface(tmp_surf);
return surf; return surf;
@ -8030,7 +8032,7 @@ static void draw_toolbar(void)
dest.x = ((i % 2) * 48) + 4 + (40 - img_tool_names[i]->w) / 2; dest.x = ((i % 2) * 48) + 4 + (40 - img_tool_names[i]->w) / 2;
dest.y = ((i / 2) * 48) + 40 + 2 + (44 - img_tool_names[i]->h); dest.y = ((i / 2) * 48) + 40 + 2 + (44 + button_label_y_nudge - img_tool_names[i]->h);
SDL_BlitSurface(img_tool_names[i], NULL, screen, &dest); SDL_BlitSurface(img_tool_names[i], NULL, screen, &dest);
} }