Fix #115938: BLF Handle Negative Left-Side Bearings

Our glyph bounds clipping test will fail for the first character of a
string if that character has negative left-side bearing. This is not
usual but can happen in some designs for lowercase "j" to have the tail
hook under the preceding character.

Pull Request: https://projects.blender.org/blender/blender/pulls/115965
This commit is contained in:
Harley Acheson 2023-12-09 01:52:45 +01:00 committed by Harley Acheson
parent f3c1111836
commit 76bf43f44d
1 changed files with 1 additions and 1 deletions

View File

@ -1368,7 +1368,7 @@ static void blf_glyph_calc_rect_test(rcti *rect, GlyphBLF *g, const int x, const
/* Intentionally check with `g->advance`, because this is the
* width used by BLF_width. This allows that the text slightly
* overlaps the clipping border to achieve better alignment. */
rect->xmin = x + g->pos[0] + 1;
rect->xmin = x + abs(g->pos[0]) + 1;
rect->xmax = x + std::min(ft_pix_to_int(g->advance_x), g->dims[0]);
rect->ymin = y;
rect->ymax = rect->ymin - g->dims[1];