Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-03-14 17:44:07 +0300
committerJacques Lucke <mail@jlucke.com>2019-03-14 17:45:21 +0300
commit7bfdf357116f0f59b254adb334ae1c24530e904f (patch)
treebbb58b6db40bc81878def6a98934f137373341f7 /source/blender/blenfont/intern
parent96db46d17c77ed1a463d8926393ed27f9a4a038d (diff)
Fix T61300: First letter truncated
The main problem was that the character `J` has "negative kerning". It was cut off because it started outside of the clipping rectangle. Reviewers: brecht Differential Revision: https://developer.blender.org/D4513
Diffstat (limited to 'source/blender/blenfont/intern')
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 27187f2e84d..4c5f598ffeb 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -437,10 +437,24 @@ static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
rect->ymax = rect->ymin - (float)g->height;
}
-void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
+static void blf_glyph_calc_rect_test(rctf *rect, GlyphBLF *g, float x, float y)
{
- rctf rect;
+ /* 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->ymin = floorf(y + MAX2(0.0f, g->pos_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)
+{
+ blf_glyph_calc_rect(rect, g,
+ x + (float)font->shadow_x,
+ y + (float)font->shadow_y);
+}
+void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
+{
if ((!g->width) || (!g->height))
return;
@@ -496,11 +510,9 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
g->build_tex = 1;
}
- blf_glyph_calc_rect(&rect, g, x, y);
-
if (font->flags & BLF_CLIPPING) {
- /* intentionally check clipping without shadow offset */
- rctf rect_test = rect;
+ rctf rect_test;
+ blf_glyph_calc_rect_test(&rect_test, g, x, y);
BLI_rctf_translate(&rect_test, font->pos[0], font->pos[1]);
if (!BLI_rctf_inside_rctf(&font->clip_rec, &rect_test)) {
@@ -518,9 +530,7 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
if (font->flags & BLF_SHADOW) {
rctf rect_ofs;
- blf_glyph_calc_rect(&rect_ofs, g,
- x + (float)font->shadow_x,
- y + (float)font->shadow_y);
+ blf_glyph_calc_rect_shadow(&rect_ofs, g, x, y, font);
if (font->shadow == 0) {
blf_texture_draw(font->shadow_color, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
@@ -535,6 +545,9 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
}
}
+ rctf rect;
+ blf_glyph_calc_rect(&rect, g, x, y);
+
#if BLF_BLUR_ENABLE
switch (font->blur) {
case 3: