From cfd909f184ccd87ed6dcfa45a5ab93d8fc5cb742 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Sun, 17 Mar 2019 14:15:26 +0100 Subject: Fix T62678: Wrong text clipping There are two issues at play here. First, BLF_width computed a width that was not wide enough to actually hold the text. Second, blf_glyph_calc_rect_test computed an incorrect rect->xmax when the glyph was moved to the left a bit. We ignore the overlap on the left, but the right side should still be adjusted accordingly. --- source/blender/blenfont/intern/blf_glyph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 4c5f598ffeb..45761a3f319 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -441,9 +441,9 @@ static void blf_glyph_calc_rect_test(rctf *rect, GlyphBLF *g, float x, float y) { /* intentionally check clipping without shadow offset and negative kerning */ rect->xmin = floorf(x + MAX2(0.0f, g->pos_x)); - rect->xmax = rect->xmin + (float)g->width; + rect->xmax = rect->xmin + (float)g->width + MIN2(0.0f, g->pos_x); rect->ymin = floorf(y + MAX2(0.0f, g->pos_y)); - rect->ymax = rect->ymin - (float)g->height; + rect->ymax = rect->ymin - (float)g->height - MIN2(0.0f, g->pos_y); } static void blf_glyph_calc_rect_shadow(rctf *rect, GlyphBLF *g, float x, float y, FontBLF *font) -- cgit v1.2.3