diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2013-03-24 11:35:27 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2013-03-24 11:35:27 +0000 |
commit | 7de97e8d6a2899a4811b494f74064989eeac1b00 (patch) | |
tree | 64ed190e01195e9a4b1e7fe022a8a09e5df4b038 /amiga | |
parent | f70e58b4a140600b7a375ecdd0991d8eee64e033 (diff) | |
download | netsurf-7de97e8d6a2899a4811b494f74064989eeac1b00.tar.gz netsurf-7de97e8d6a2899a4811b494f74064989eeac1b00.tar.bz2 |
ensure the closest character is picked
Diffstat (limited to 'amiga')
-rw-r--r-- | amiga/font.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/amiga/font.c b/amiga/font.c index ee5ab303c..df0567f09 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -216,7 +216,7 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle, outf16 = utf16; if(!(ofont = ami_open_outline_font(fstyle, 0))) return false; - *char_offset = length; + *char_offset = 0; *actual_x = 0; while (utf8_pos < length) { @@ -239,17 +239,20 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle, } tx += tempx; + utf16 += utf16charlen; + utf8_pos = utf8_next(string, length, utf8_pos); if(tx < x) { *actual_x = tx; - } else { *char_offset = utf8_pos; + } else { + if((x - *actual_x) > (tx - x)) { + *actual_x = tx; + *char_offset = utf8_pos; + } free(outf16); return true; } - - utf16 += utf16charlen; - utf8_pos = utf8_next(string, length, utf8_pos); } *actual_x = tx; |