diff options
author | Jacques Lucke <mail@jlucke.com> | 2019-03-20 15:33:08 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-03-20 15:33:52 +0300 |
commit | 1b1b60459686de36cb8e307d8fce711bc6cf87af (patch) | |
tree | 115b86d5b9d99c8a4081b6a727767be918f22796 /source/blender/blenfont/intern/blf_glyph.c | |
parent | d6bf6744fca0773ab074621271adc0c03cc0c0df (diff) |
Fix T62678: better glyph clipping test
Reviewers: billreynish, brecht
Differential Revision: https://developer.blender.org/D4550
Diffstat (limited to 'source/blender/blenfont/intern/blf_glyph.c')
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 45761a3f319..27e67f700bc 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -439,11 +439,13 @@ static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y) 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 + MIN2(0.0f, g->pos_x); - rect->ymin = floorf(y + MAX2(0.0f, g->pos_y)); - rect->ymax = rect->ymin - (float)g->height - MIN2(0.0f, g->pos_y); + /* 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 = floorf(x); + rect->xmax = rect->xmin + MIN2(g->advance, (float)g->width); + rect->ymin = floorf(y); + rect->ymax = rect->ymin - (float)g->height; } static void blf_glyph_calc_rect_shadow(rctf *rect, GlyphBLF *g, float x, float y, FontBLF *font) |