mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-03-01 04:44:19 +03:00
Fix freetype nsfont_position_in_string to return nearest, rather than next.
This commit is contained in:
parent
a92f2aa0a6
commit
c0bfe7dfdf
@ -462,6 +462,7 @@ static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
|
||||
uint32_t ucs4;
|
||||
size_t nxtchr = 0;
|
||||
FT_Glyph glyph;
|
||||
int prev_x = 0;
|
||||
|
||||
*actual_x = 0;
|
||||
while (nxtchr < length) {
|
||||
@ -475,9 +476,14 @@ static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
|
||||
if (*actual_x > x)
|
||||
break;
|
||||
|
||||
prev_x = *actual_x;
|
||||
nxtchr = utf8_next(string, length, nxtchr);
|
||||
}
|
||||
|
||||
/* choose nearest of previous and last x */
|
||||
if (abs(*actual_x - x) > abs(prev_x - x))
|
||||
*actual_x = prev_x;
|
||||
|
||||
*char_offset = nxtchr;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user