From 936cb38b5e0e67c50cf35d23f81059b4a6493ce8 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sun, 10 Mar 2013 21:21:37 -0400 Subject: Center text without needing endless spaces; also support \n in centered text. * Text positioning in message boxes is now controlled by #defines. * The various MSG_PLAY_SLIDE messages are now one, MSG_SCREENSHOT_SLIDESHOW_KEYS, with \n between lines. * Use \n in some more message pairs. * Lengthy scrollers broke. This will be investigated in a later commit. --- source/nds/bdf_font.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source/nds/bdf_font.c') 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; + } } -- cgit v1.2.3