diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-03-20 20:06:24 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-03-20 20:06:24 +0000 |
commit | 5d7b1f40a300763feaaa0de473e9b5b30a1b541b (patch) | |
tree | 8fed185193f55a81bc37374c37556c3025f0503e /amiga/font.c | |
parent | 8e360ff0403523409a7c2edcea9acdf46f4b8605 (diff) | |
download | netsurf-5d7b1f40a300763feaaa0de473e9b5b30a1b541b.tar.gz netsurf-5d7b1f40a300763feaaa0de473e9b5b30a1b541b.tar.bz2 |
Another attempt.
Diffstat (limited to 'amiga/font.c')
-rw-r--r-- | amiga/font.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/amiga/font.c b/amiga/font.c index 620d56d53..3afab2dcf 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -240,7 +240,7 @@ bool nsfont_split(const plot_font_style_t *fstyle, int x, size_t *char_offset, int *actual_x) { ULONG co; - char *ostr = (char *)string; + const char *str_pos = string; uint16 *utf16 = NULL,*outf16 = NULL; uint16 utf16next = 0; FIXED kern = 0; @@ -262,7 +262,8 @@ bool nsfont_split(const plot_font_style_t *fstyle, *actual_x = 0; while(utf8clen < length) { - utf8len = utf8_char_byte_length(string + utf8clen); + str_pos += utf8clen; + utf8len = utf8_char_byte_length(str_pos); if ((*utf16 < 0xD800) || (0xDFFF < *utf16)) utf16charlen = 1; @@ -294,13 +295,18 @@ bool nsfont_split(const plot_font_style_t *fstyle, tx += tempx; - if((x < tx) && (coffset != 0)) { + if ((x < tx) && (coffset != 0)) { /* We've run out of space, and a space has been found, split there. */ break; - } else if (*utf16 == 0x0020) { + } else if (*str_pos == ' ') { *actual_x = tx; coffset = utf8clen; + + if (x < tx) { + /* Out of space, so don't look further */ + break; + } } utf16 += utf16charlen; utf8clen += utf8len; |