From f9ea0e0f6e615dcd7400dcff296d1332a237bd63 Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Fri, 27 Jul 2007 01:53:08 +0000 Subject: [PATCH] Right-aligning right-to-left text. --- src/tuxpaint.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 5813ca765..21f5570bf 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -9541,6 +9541,12 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, if (need_own_font && (strcmp(gettext(str), str) || locale_text)) myfont = locale_font; + if (strcmp(str, gettext(str)) == 0) + { + /* String isn't translated! Don't write right-to-left */ + want_right_to_left = 0; + } + #ifndef NO_SDLPANGO /* Letting SDL_Pango do all this stuff! */ @@ -9549,7 +9555,10 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, SDLPango_SetDefaultColor(myfont->pango_context, &pango_color); SDLPango_SetMinimumSize(myfont->pango_context, right - left, canvas->h - top); - SDLPango_SetText(myfont->pango_context, gettext(str), -1); + if (want_right_to_left) + SDLPango_SetText_GivenAlignment(myfont->pango_context, gettext(str), -1, SDLPANGO_ALIGN_RIGHT); + else + SDLPango_SetText(myfont->pango_context, gettext(str), -1); text = SDLPango_CreateSurfaceDraw(myfont->pango_context); dest.x = left; @@ -9574,20 +9583,10 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, if (strcmp(str, "") != 0) { - if (strcmp(str, gettext(str)) == 0) - { - /* String isn't translated! Don't write right-to-left */ - want_right_to_left = 0; - } - -#ifdef NO_SDLPANGO if (want_right_to_left == 0) locale_str = (unsigned char *) strdup(gettext(str)); else locale_str = (unsigned char *) textdir(gettext(str)); -#else - locale_str = (unsigned char *) strdup(gettext(str)); -#endif /* For each UTF8 character: */