[Bf-blender-cvs] [1b1b6045968] master: Fix T62678: better glyph clipping test

Jacques Lucke noreply at git.blender.org
Wed Mar 20 13:34:16 CET 2019


Commit: 1b1b60459686de36cb8e307d8fce711bc6cf87af
Author: Jacques Lucke
Date:   Wed Mar 20 13:33:08 2019 +0100
Branches: master
https://developer.blender.org/rB1b1b60459686de36cb8e307d8fce711bc6cf87af

Fix T62678: better glyph clipping test

Reviewers: billreynish, brecht

Differential Revision: https://developer.blender.org/D4550

===================================================================

M	source/blender/blenfont/intern/blf_glyph.c

===================================================================

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)



More information about the Bf-blender-cvs mailing list