aboutsummaryrefslogtreecommitdiff
path: root/source/nds/bdf_font.c
diff options
context:
space:
mode:
authorNebuleon Fumika2013-03-10 21:21:37 -0400
committerNebuleon Fumika2013-03-10 21:21:37 -0400
commit936cb38b5e0e67c50cf35d23f81059b4a6493ce8 (patch)
treedcc10e90f203b98dfe41b3c5d91d8c7e277ffaa7 /source/nds/bdf_font.c
parent47a63742d7aae6578b74929d7957c86ef1e699be (diff)
downloadsnes9x2005-936cb38b5e0e67c50cf35d23f81059b4a6493ce8.tar.gz
snes9x2005-936cb38b5e0e67c50cf35d23f81059b4a6493ce8.tar.bz2
snes9x2005-936cb38b5e0e67c50cf35d23f81059b4a6493ce8.zip
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<n> 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.
Diffstat (limited to 'source/nds/bdf_font.c')
-rw-r--r--source/nds/bdf_font.c19
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;
+ }
}