Treat CJK characters as words.

Patch by Yen-Ju Chen <yjchenx@hotmail.com>.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26022 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2008-02-04 10:46:20 +00:00
parent 40833fa7e5
commit deca87da4a
2 changed files with 35 additions and 14 deletions

View file

@ -1,3 +1,9 @@
2008-02-04 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSHorizontalTypesetter.m
(-breakLineByWordWrappingBefore:): Treat CJK characters as words.
Patch by Yen-Ju Chen <yjchenx@hotmail.com>.
2008-02-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSButtonCell.m

View file

@ -258,21 +258,36 @@ including gi will have been cached.
while (gi > 0)
{
if (g->g == NSControlGlyph)
return gi + cache_base;
return gi + cache_base;
ch = [str characterAtIndex: g->char_index];
if (ch == 0x20 || ch == 0x0a || ch == 0x0d /* TODO: paragraph/line separator */)
{
g->dont_show = YES;
if (gi > 0)
{
g->pos = g[-1].pos;
g->pos.x += g[-1].size.width;
}
else
g->pos = NSMakePoint(0, 0);
g->size.width = 0;
return gi + 1 + cache_base;
}
/* TODO: paragraph/line separator */
if (ch == 0x20 || ch == 0x0a || ch == 0x0d)
{
g->dont_show = YES;
if (gi > 0)
{
g->pos = g[-1].pos;
g->pos.x += g[-1].size.width;
}
else
g->pos = NSMakePoint(0, 0);
g->size.width = 0;
return gi + 1 + cache_base;
}
/* Each CJK glyph should be treated as a word when wrapping word.
The range should work for most cases */
else if ((ch > 0x2ff0) && (ch < 0x9fff))
{
g->dont_show = NO;
if (gi > 0)
{
g->pos = g[-1].pos;
g->pos.x += g[-1].size.width;
}
else
g->pos = NSMakePoint(0,0);
return gi + cache_base;
}
gi--;
g--;
}