Hebrew blits top-to-bottom (was blitting bottom-to-top), and is right-justified.

This commit is contained in:
William Kendrick 2003-05-23 07:53:02 +00:00
parent a15d385969
commit e4009ae2c9
6 changed files with 127 additions and 35 deletions

View file

@ -7,7 +7,7 @@ bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/ http://www.newbreedsoftware.com/tuxpaint/
June 17, 2002 - April 25, 2003 June 17, 2002 - May 23, 2003
* Design and Coding: * Design and Coding:

View file

@ -7,7 +7,7 @@ bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/ http://www.newbreedsoftware.com/tuxpaint/
2003.May.22 (0.9.11) [cvs] 2003.May.23 (0.9.11) [cvs]
* Windows bugfixes. * Windows bugfixes.
John Popplewell <john@johnnypops.demon.co.uk> John Popplewell <john@johnnypops.demon.co.uk>
@ -19,6 +19,8 @@ http://www.newbreedsoftware.com/tuxpaint/
Dovix <dovix2003@yahoo.com> Dovix <dovix2003@yahoo.com>
Koby <kobybo@hotmail.com> Koby <kobybo@hotmail.com>
* Right-to-left language support (for Hebrew, for example).
* Updated Korean translations. * Updated Korean translations.
Mark K. Kim <mark@cbreak.org> Mark K. Kim <mark@cbreak.org>

View file

@ -9,7 +9,7 @@
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/ http://www.newbreedsoftware.com/tuxpaint/
June 14, 2002 - May 22, 2003 June 14, 2002 - May 23, 2003
---------------------------------------------------------------------- ----------------------------------------------------------------------

View file

@ -6,7 +6,7 @@ Copyright (c) 2003 by Bill Kendrick
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/ http://www.newbreedsoftware.com/tuxpaint/
May 22, 2003 May 23, 2003
LOW-PRIORITY DOCUMENTATION CHANGES: LOW-PRIORITY DOCUMENTATION CHANGES:
@ -81,6 +81,9 @@ HIGH-PRIORITY TRANSLATION STUFF:
-------------------------------- --------------------------------
* Right-justify right-to-left strings. * Right-justify right-to-left strings.
* Make right-to-left strings not wordwrap with the shortest line at
the top!
* Finish current translations. * Finish current translations.
* Fix Romanian! * Fix Romanian!

View file

@ -21,7 +21,7 @@ New Breed Software</p>
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br> <p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p> <a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p>
<p>June 14, 2002 - May 22, 2003</p> <p>June 14, 2002 - May 23, 2003</p>
</center> </center>
<hr size=2 noshade> <hr size=2 noshade>

View file

@ -7,12 +7,12 @@
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/ http://www.newbreedsoftware.com/tuxpaint/
June 14, 2002 - May 22, 2003 June 14, 2002 - May 23, 2003
*/ */
#define VER_VERSION "0.9.11" #define VER_VERSION "0.9.11"
#define VER_DATE "2003.05.22" #define VER_DATE "2003.05.23"
/* #define DEBUG */ /* #define DEBUG */
@ -557,9 +557,12 @@ void convert_close();
char * convert2utf8(char c); char * convert2utf8(char c);
int converts(); int converts();
int delete_utf8_char(char * utf8_str, int len); int delete_utf8_char(char * utf8_str, int len);
#define MAX_UTF8_CHAR_LENGTH 6 void anti_carriage_return(int left, int right, int cur_top, int new_top,
int cur_bot, int line_width);
#define MAX_UTF8_CHAR_LENGTH 6
#define USEREVENT_TEXT_UPDATE 1 #define USEREVENT_TEXT_UPDATE 1
@ -6333,9 +6336,9 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
unsigned char utf8_char[5]; unsigned char utf8_char[5];
int len; int len;
SDL_Surface * text; SDL_Surface * text;
SDL_Rect dest; SDL_Rect dest, src;
int utf8_str_len; int utf8_str_len, last_text_height;
unsigned char utf8_str[512]; unsigned char utf8_str[512];
@ -6344,6 +6347,8 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
x = left; x = left;
y = top; y = top;
last_text_height = 0;
debug(str); debug(str);
debug(gettext(str)); debug(gettext(str));
debug("..."); debug("...");
@ -6384,6 +6389,10 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
if (x > left) if (x > left)
{ {
if (need_right_to_left(language))
anti_carriage_return(left, right, top, top + text->h, y + text->h,
x - left);
x = left; x = left;
y = y + text->h; y = y + text->h;
} }
@ -6391,6 +6400,7 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
/* Junk the blitted word; it's too long! */ /* Junk the blitted word; it's too long! */
last_text_height = text->h;
SDL_FreeSurface(text); SDL_FreeSurface(text);
@ -6439,18 +6449,24 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
{ {
if (x + text->w > right) if (x + text->w > right)
{ {
x = left; if (need_right_to_left(language))
anti_carriage_return(left, right, top, top + text->h,
y + text->h, x - left);
x = left;
y = y + text->h; y = y + text->h;
} }
//if (need_right_to_left(language) == 0) dest.x = x;
dest.x = x;
//else
// dest.x = right - (x - left) - text->w;
dest.y = y; if (need_right_to_left(language))
dest.y = top;
else
dest.y = y;
SDL_BlitSurface(text, NULL, screen, &dest); SDL_BlitSurface(text, NULL, screen, &dest);
last_text_height = text->h;
SDL_FreeSurface(text); SDL_FreeSurface(text);
x = x + text->w; x = x + text->w;
@ -6466,18 +6482,24 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
{ {
/* This word needs to move down? */ /* This word needs to move down? */
x = left; if (need_right_to_left(language))
anti_carriage_return(left, right, top, top + text->h, y + text->h,
x - left);
x = left;
y = y + text->h; y = y + text->h;
} }
//if (need_right_to_left(language) == 0) dest.x = x;
dest.x = x;
//else
// dest.x = right - (x - left) - text->w;
dest.y = y; if (need_right_to_left(language))
dest.y = top;
else
dest.y = y;
SDL_BlitSurface(text, NULL, screen, &dest); SDL_BlitSurface(text, NULL, screen, &dest);
last_text_height = text->h;
SDL_FreeSurface(text); SDL_FreeSurface(text);
x = x + text->w; x = x + text->w;
} }
@ -6537,22 +6559,27 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
if (x + text->w > right) if (x + text->w > right)
{ {
if (need_right_to_left(language))
anti_carriage_return(left, right, top, top + text->h, y + text->h,
x - left);
x = left; x = left;
y = y + text->h; y = y + text->h;
} }
//if (need_right_to_left(language) == 0)
dest.x = x; dest.x = x;
//else
// dest.x = right - (x - left) - text->w;
dest.y = y; if (need_right_to_left(language))
dest.y = top;
else
dest.y = y;
SDL_BlitSurface(text, NULL, screen, &dest); SDL_BlitSurface(text, NULL, screen, &dest);
x = x + text->w; x = x + text->w;
last_text_height = text->h;
SDL_FreeSurface(text); SDL_FreeSurface(text);
} }
@ -6597,19 +6624,23 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
if (x + text->w > right) /* Correct? */ if (x + text->w > right) /* Correct? */
{ {
x = left; if (need_right_to_left(language))
anti_carriage_return(left, right, top, top + text->h, y + text->h,
x - left);
x = left;
y = y + text->h; y = y + text->h;
} }
/* Draw the word: */ /* Draw the word: */
//if (need_right_to_left(language) == 0) dest.x = x;
dest.x = x;
//else
// dest.x = right - (x - left) - text->w;
dest.y = y; if (need_right_to_left(language))
dest.y = top;
else
dest.y = y;
SDL_BlitSurface(text, NULL, screen, &dest); SDL_BlitSurface(text, NULL, screen, &dest);
@ -6621,6 +6652,7 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
/* Free the temp. surface: */ /* Free the temp. surface: */
last_text_height = text->h;
SDL_FreeSurface(text); SDL_FreeSurface(text);
@ -6631,6 +6663,29 @@ void wordwrap_text(TTF_Font * font, char * str, SDL_Color color,
free(tstr); free(tstr);
} }
/* Right-justify the final line of text, in right-to-left mode: */
if (need_right_to_left(language) && last_text_height > 0)
{
src.x = left;
src.y = top;
src.w = x - left;
src.h = last_text_height;
dest.x = right - src.w;
dest.y = top;
SDL_BlitSurface(screen, &src, screen, &dest);
dest.x = left;
dest.y = top;
dest.w = (right - left - src.w);
dest.h = last_text_height;
SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 192, 192, 192));
}
} }
@ -7262,7 +7317,7 @@ int do_prompt(char * text, char * btn_yes, char * btn_no)
/* Draw the question: */ /* Draw the question: */
wordwrap_text(font, text, black, wordwrap_text(font, text, black,
166 + PROMPTOFFSETX, 100 + PROMPTOFFSETY, 482, 0, 0); 166 + PROMPTOFFSETX, 100 + PROMPTOFFSETY, 475, 0, 0);
/* Draw yes button: */ /* Draw yes button: */
@ -7272,7 +7327,7 @@ int do_prompt(char * text, char * btn_yes, char * btn_no)
SDL_BlitSurface(img_yes, NULL, screen, &dest); SDL_BlitSurface(img_yes, NULL, screen, &dest);
wordwrap_text(font, btn_yes, black, 166 + PROMPTOFFSETX + 48 + 4, wordwrap_text(font, btn_yes, black, 166 + PROMPTOFFSETX + 48 + 4,
183 + PROMPTOFFSETY, 482, 0, 0); 183 + PROMPTOFFSETY, 475, 0, 0);
/* Draw no button: */ /* Draw no button: */
@ -7284,7 +7339,7 @@ int do_prompt(char * text, char * btn_yes, char * btn_no)
SDL_BlitSurface(img_no, NULL, screen, &dest); SDL_BlitSurface(img_no, NULL, screen, &dest);
wordwrap_text(font, btn_no, black, wordwrap_text(font, btn_no, black,
166 + PROMPTOFFSETX + 48 + 4, 235 + PROMPTOFFSETY, 482, 0, 0); 166 + PROMPTOFFSETX + 48 + 4, 235 + PROMPTOFFSETY, 475, 0, 0);
} }
@ -11117,3 +11172,35 @@ int delete_utf8_char(char *utf8_str, int len)
} }
/* For right-to-left languages, when word-wrapping, we need to
make sure the text doesn't end up going from bottom-to-top, too! */
void anti_carriage_return(int left, int right, int cur_top, int new_top,
int cur_bot, int line_width)
{
SDL_Rect src, dest;
/* Move current set of text down one line (and right-justify it!): */
src.x = left;
src.y = cur_top;
src.w = line_width;
src.h = cur_bot - cur_top;
dest.x = right - line_width;
dest.y = new_top;
SDL_BlitSurface(screen, &src, screen, &dest);
/* Clear the top line for new text: */
dest.x = left;
dest.y = cur_top;
dest.w = right - left;
dest.h = new_top - cur_top;
SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 255, 255, 255));
}