diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-02-10 18:26:59 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-02-10 18:26:59 +0000 |
commit | 3148f8a6c34c4d41652132595fe0fce99750cc5a (patch) | |
tree | 3bdaed2fb25f5364fb0f7714ede6252be0d9203e /framebuffer/font_freetype.c | |
parent | db8ec60fc04930a0dc03a67853af9cffaf4fc4bf (diff) | |
download | netsurf-3148f8a6c34c4d41652132595fe0fce99750cc5a.tar.gz netsurf-3148f8a6c34c4d41652132595fe0fce99750cc5a.tar.bz2 |
Make compatible with new nsfont_split expectations. Only splits on spaces.
Diffstat (limited to 'framebuffer/font_freetype.c')
-rw-r--r-- | framebuffer/font_freetype.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/framebuffer/font_freetype.c b/framebuffer/font_freetype.c index c2279a116..987b101c7 100644 --- a/framebuffer/font_freetype.c +++ b/framebuffer/font_freetype.c @@ -497,15 +497,22 @@ static bool nsfont_position_in_string(const plot_font_style_t *fstyle, * * \param fstyle style for this text * \param string UTF-8 string to measure - * \param length length of string + * \param length length of string, in bytes * \param x width available - * \param char_offset updated to offset in string of actual_x, [0..length] + * \param char_offset updated to offset in string of actual_x, [1..length] * \param actual_x updated to x coordinate of character closest to x * \return true on success, false on error and error reported * - * On exit, [char_offset == 0 || - * string[char_offset] == ' ' || - * char_offset == length] + * On exit, char_offset indicates first character after split point. + * + * Note: char_offset of 0 should never be returned. + * + * Returns: + * char_offset giving split point closest to x, where actual_x <= x + * else + * char_offset giving split point closest to x, where actual_x > x + * + * Returning char_offset == length means no split possible */ static bool nsfont_split(const plot_font_style_t *fstyle, @@ -532,10 +539,9 @@ static bool nsfont_split(const plot_font_style_t *fstyle, } *actual_x += glyph->advance.x >> 16; - if (*actual_x > x) { - /* string has exceeded available width return previous - * space - */ + if (*actual_x > x && last_space_idx != 0) { + /* string has exceeded available width and we've + * found a space; return previous space */ *actual_x = last_space_x; *char_offset = last_space_idx; return true; |