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:
Diffstat (limited to 'source/blender/blenfont/intern/blf_font.c')
-rw-r--r--source/blender/blenfont/intern/blf_font.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 5161761cf09..9a7fb95dd78 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -129,7 +129,7 @@ static void blf_font_ensure_ascii_table(FontBLF *font)
g= (glyph_ascii_table)[c]; \
i++; \
} \
- else if ((c= blf_utf8_next((unsigned char *)(str), &(i)))) { \
+ else if ((c= blf_utf8_next((str), &(i))) != BLI_UTF8_ERR) { \
if ((g= blf_glyph_search((font)->glyph_cache, c)) == NULL) { \
g= blf_glyph_add(font, FT_Get_Char_Index((font)->face, c), c); \
} \
@@ -141,15 +141,20 @@ static void blf_font_ensure_ascii_table(FontBLF *font)
const FT_UInt kern_mode= (has_kerning == 0) ? 0 : \
(((_font)->flags & BLF_KERNING_DEFAULT) ? \
ft_kerning_default : FT_KERNING_UNFITTED) \
- \
#define BLF_KERNING_STEP(_font, kern_mode, g_prev, g, delta, pen_x) \
{ \
if (g_prev) { \
delta.x= delta.y= 0; \
- if (FT_Get_Kerning((_font)->face, g_prev->idx, g->idx, kern_mode, &delta) == 0) \
+ if (FT_Get_Kerning((_font)->face, \
+ (g_prev)->idx, \
+ (g)->idx, \
+ kern_mode, \
+ &(delta)) == 0) \
+ { \
pen_x += delta.x >> 6; \
+ } \
} \
} \
@@ -159,7 +164,7 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len)
GlyphBLF *g, *g_prev= NULL;
FT_Vector delta;
int pen_x= 0, pen_y= 0;
- unsigned int i= 0;
+ size_t i= 0;
GlyphBLF **glyph_ascii_table= font->glyph_cache->glyph_ascii_table;
BLF_KERNING_VARS(font, has_kerning, kern_mode);
@@ -170,9 +175,9 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len)
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
- if (c == 0) break;
- if (g == NULL) continue;
- if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
+ if (c == BLI_UTF8_ERR) break;
+ if (g == NULL) continue;
+ if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
/* do not return this loop if clipped, we want every character tested */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
@@ -214,7 +219,7 @@ void blf_font_buffer(FontBLF *font, const char *str)
GlyphBLF *g, *g_prev= NULL;
FT_Vector delta;
int pen_x= (int)font->pos[0], pen_y= 0;
- unsigned int i= 0;
+ size_t i= 0;
GlyphBLF **glyph_ascii_table= font->glyph_cache->glyph_ascii_table;
/* buffer specific vars*/
@@ -235,9 +240,9 @@ void blf_font_buffer(FontBLF *font, const char *str)
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
- if (c == 0) break;
- if (g == NULL) continue;
- if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
+ if (c == BLI_UTF8_ERR) break;
+ if (g == NULL) continue;
+ if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
chx= pen_x + ((int)g->pos_x);
chy= (int)font->pos[1] + g->height;
@@ -340,7 +345,7 @@ void blf_font_boundbox(FontBLF *font, const char *str, rctf *box)
GlyphBLF *g, *g_prev= NULL;
FT_Vector delta;
int pen_x= 0, pen_y= 0;
- unsigned int i= 0;
+ size_t i= 0;
GlyphBLF **glyph_ascii_table= font->glyph_cache->glyph_ascii_table;
rctf gbox;
@@ -358,9 +363,9 @@ void blf_font_boundbox(FontBLF *font, const char *str, rctf *box)
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
- if (c == 0) break;
- if (g == NULL) continue;
- if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
+ if (c == BLI_UTF8_ERR) break;
+ if (g == NULL) continue;
+ if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
gbox.xmin= pen_x;
gbox.xmax= pen_x + g->advance;