diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-16 06:57:54 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-08-16 07:35:38 +0300 |
commit | 87adcbc94fc78d2c227aff992d045b287fcf2337 (patch) | |
tree | 294213ff30d6633858be31c502effbd73e475b34 /source | |
parent | 6aebbe6a0a2a52df3ff127b6ad28da494661b992 (diff) |
BLF: use fast ASCII kerning for word-wrap calculations
While this wasn't a bottleneck, using the fast version of this function
removes some duplicate code that doesn't use the look-up table.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index a0c146a974d..512e2babf74 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -383,17 +383,6 @@ BLI_INLINE void blf_kerning_step_fast(FontBLF *font, } } -BLI_INLINE void blf_kerning_step( - FontBLF *font, const FT_UInt kern_mode, const GlyphBLF *g_prev, const GlyphBLF *g, int *pen_x) -{ - if (g_prev != NULL) { - FT_Vector delta; - if (FT_Get_Kerning(font->face, g_prev->idx, g->idx, kern_mode, &delta) == 0) { - *pen_x += (int)delta.x >> 6; - } - } -} - static void blf_font_draw_ex(FontBLF *font, GlyphCacheBLF *gc, const char *str, @@ -913,7 +902,7 @@ static void blf_font_wrap_apply(FontBLF *font, void *userdata), void *userdata) { - unsigned int c; + unsigned int c, c_prev = BLI_UTF8_ERR; GlyphBLF *g, *g_prev = NULL; int pen_x = 0, pen_y = 0; size_t i = 0; @@ -924,6 +913,8 @@ static void blf_font_wrap_apply(FontBLF *font, BLF_KERNING_VARS(font, has_kerning, kern_mode); + blf_font_ensure_ascii_kerning(font, gc, kern_mode); + struct WordWrapVars { int wrap_width; size_t start, last[2]; @@ -945,7 +936,7 @@ static void blf_font_wrap_apply(FontBLF *font, continue; } if (has_kerning) { - blf_kerning_step(font, kern_mode, g_prev, g, &pen_x); + blf_kerning_step_fast(font, kern_mode, g_prev, g, c_prev, c, &pen_x); } /** @@ -986,12 +977,14 @@ static void blf_font_wrap_apply(FontBLF *font, pen_x = 0; pen_y -= gc->glyph_height_max; g_prev = NULL; + c_prev = BLI_UTF8_ERR; lines += 1; continue; } pen_x = pen_x_next; g_prev = g; + c_prev = c; } // printf("done! lines: %d, width, %d\n", lines, pen_x_next); |