diff options
author | François Revol <revol@free.fr> | 2013-03-21 22:10:35 +0100 |
---|---|---|
committer | François Revol <revol@free.fr> | 2013-03-21 22:10:35 +0100 |
commit | 1f9e1ca84b0db9591ac0fb204ead59c10ee8b9fe (patch) | |
tree | fe897ce23f2e21dd313f2e8089e666af39136d81 | |
parent | ad53da023d7126286d2b8944d52ecf65ff801a24 (diff) | |
download | netsurf-1f9e1ca84b0db9591ac0fb204ead59c10ee8b9fe.tar.gz netsurf-1f9e1ca84b0db9591ac0fb204ead59c10ee8b9fe.tar.bz2 |
beos: Fix nsfont_position_in_string off-by-1
The current width was tested after the index was already
updated to the next character, leading to an off-by-one error,
and the impossibility to select the first character of a string
in textarea.
-rw-r--r-- | beos/font.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/beos/font.cpp b/beos/font.cpp index c2d5e7b9b..b73c9cc1a 100644 --- a/beos/font.cpp +++ b/beos/font.cpp @@ -141,11 +141,12 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle, font.GetEscapements(string, len, escapements); // slow but it should work for (i = 0; string[index] && i < len; i++) { - if (x < current) - break; esc += escapements[i]; current = font.Size() * esc; index += utf8_char_len(&string[index]); + // is current char already too far away? + if (x < current) + break; } *actual_x = (int)current; *char_offset = i; //index; |