From: Peter W. <pet...@we...> - 2009-10-28 12:54:16
|
Brian Wang schrieb: > Hello all, > > Evas's word-wrapping calculation does not work well with long Chinese strings. > This is how it looks (no wrapping): > http://cool-idea.com.tw/brian/edje-long-chinese-text-orig.png > > I made my effort to make it work with Chinese but it is certainly not > for the majority. > This is how the patched one looks: > http://cool-idea.com.tw/brian/edje-long-chinese-text-patched.png > > I'm not an expert of UTF-8 encoding but there must be some simple way > of making everyone happy with the word wrapping. > Comments are welcome. :-) > Your patch assumes that an UTF8 character initiates a new word. That is wrong for the most European language, if not for all. So there must be another solution. Maybe a hybrid of word and character wrap? I.e. try to wrap a word (separated by a white space) first, if this is not possible, do a character wrap. I don't know if this is a good solution. But it would work at least for European languages and Chinese more or less. Regards Peter > Here is the simple patch: > Index: canvas/evas_object_textblock.c > =================================================================== > --- canvas/evas_object_textblock.c (revision 43223) > +++ canvas/evas_object_textblock.c (working copy) > @@ -1607,6 +1607,16 @@ > _layout_word_start(char *str, int start) > { > int p, tp, chr = 0; > + > + // > + // coolbrian: break if the word is not within the ASCII range > + // @note This is good for breaking up Chinese words, which are > made of Chinese characters. > + // Chinese characters do not look strange if they are not > grouped to form a 'phrase'. > + // Also, Chinese 'phrases' are of too many patterns and > probably need a dictionary to look up. > + // That would be too much. > + // > + if (((unsigned char)str[start]) >= 0x80) > + return start; > > p = start; > chr = evas_common_font_utf8_get_next((unsigned char *)(str), &p); > > > |