From 1f9e1ca84b0db9591ac0fb204ead59c10ee8b9fe Mon Sep 17 00:00:00 2001 From: François Revol Date: Thu, 21 Mar 2013 22:10:35 +0100 Subject: 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. --- beos/font.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'beos') 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; -- cgit v1.2.3