diff options
Diffstat (limited to 'source/nds/bdf_font.c')
-rw-r--r-- | source/nds/bdf_font.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/source/nds/bdf_font.c b/source/nds/bdf_font.c index 92b8923..aff3b94 100644 --- a/source/nds/bdf_font.c +++ b/source/nds/bdf_font.c @@ -1022,14 +1022,14 @@ u32 BDF_cut_string(char *string, u32 width, u32 direction) /*----------------------------------------------------------------------------- - count UNICODE charactor numbers in width pixels -- direction 0: count UNICODE charactor numbers in width pixels, from front -- direction 1: count UNICODE charactor numbers in width pixels, from end +- direction 0: count UNICODE charactor numbers in width pixels, from end +- direction 1: count UNICODE charactor numbers in width pixels, from front - direction 2: conut total pixel width of len UNICODE charachtors, from end - direction 3: conut total pixel width of len UNICODE charachtors, from front ------------------------------------------------------------------------------*/ u32 BDF_cut_unicode(u16 *unicodes, u32 len, u32 width, u32 direction) { - u32 i, xw, num; + u32 i, lastSpace = 0, xw, num; u16 unicode; u32 start, end; struct bdffont *bdf_fontp[2]; @@ -1049,14 +1049,19 @@ u32 BDF_cut_unicode(u16 *unicodes, u32 len, u32 width, u32 direction) while(len > 0) { unicode= unicodes[i]; + if (unicode == 0x0A) + return num - len; + else if (unicode == ' ') + lastSpace = len; + xw += BDF_width16_ucs(unicode); - if(xw >= width) break; + if(xw > width) return num - lastSpace; i += direction; len--; } - num -= len; + return num - len; } else { @@ -1073,9 +1078,9 @@ u32 BDF_cut_unicode(u16 *unicodes, u32 len, u32 width, u32 direction) } num= xw; - } - return num; + return num; + } } |