diff options
Diffstat (limited to 'source/blender/blenfont/intern/blf_font.c')
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 65 |
1 files changed, 20 insertions, 45 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index a3c5232cc76..affc35ea11e 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -101,8 +101,8 @@ void blf_font_draw(FontBLF *font, char *str) GlyphBLF *g, *g_prev; FT_Vector delta; FT_UInt glyph_index, g_prev_index; - float pen_x, pen_y, old_pen_x; - int i, has_kerning; + int pen_x, pen_y; + int i, has_kerning, st; if (!font->glyph_cache) return; @@ -139,33 +139,21 @@ void blf_font_draw(FontBLF *font, char *str) else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data)) g= blf_glyph_add(font, glyph_index, c); - if ((font->flags & BLF_FONT_KERNING) && has_kerning && g_prev) { - old_pen_x= pen_x; + if (has_kerning && g_prev) { delta.x= 0; delta.y= 0; - if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { - pen_x += delta.x >> 6; - - if (font->flags & BLF_OVERLAP_CHAR) { - if (pen_x < old_pen_x) - pen_x= old_pen_x; - } - } - } + if (font->flags & BLF_KERNING_DEFAULT) + st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta); + else + st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); - if (font->flags & BLF_USER_KERNING) { - old_pen_x= pen_x; - pen_x += font->kerning; - - if (font->flags & BLF_OVERLAP_CHAR) { - if (pen_x < old_pen_x) - pen_x= old_pen_x; - } + if (st == 0) + pen_x += delta.x >> 6; } /* do not return this loop if clipped, we want every character tested */ - blf_glyph_render(font, g, pen_x, pen_y); + blf_glyph_render(font, g, (float)pen_x, (float)pen_y); pen_x += g->advance; g_prev= g; @@ -180,8 +168,8 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) FT_Vector delta; FT_UInt glyph_index, g_prev_index; rctf gbox; - float pen_x, pen_y, old_pen_x; - int i, has_kerning; + int pen_x, pen_y; + int i, has_kerning, st; if (!font->glyph_cache) return; @@ -223,29 +211,17 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data)) g= blf_glyph_add(font, glyph_index, c); - if ((font->flags & BLF_FONT_KERNING) && has_kerning && g_prev) { - old_pen_x= pen_x; + if (has_kerning && g_prev) { delta.x= 0; delta.y= 0; - if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { - pen_x += delta.x >> 6; - - if (font->flags & BLF_OVERLAP_CHAR) { - if (pen_x < old_pen_x) - pen_x= old_pen_x; - } - } - } + if (font->flags & BLF_KERNING_DEFAULT) + st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta); + else + st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); - if (font->flags & BLF_USER_KERNING) { - old_pen_x= pen_x; - pen_x += font->kerning; - - if (font->flags & BLF_OVERLAP_CHAR) { - if (pen_x < old_pen_x) - pen_x= old_pen_x; - } + if (st == 0) + pen_x += delta.x >> 6; } gbox.xmin= g->box.xmin + pen_x; @@ -329,10 +305,9 @@ void blf_font_fill(FontBLF *font) font->clip_rec.xmax= 0.0f; font->clip_rec.ymin= 0.0f; font->clip_rec.ymax= 0.0f; - font->flags= BLF_USER_KERNING | BLF_FONT_KERNING; + font->flags= 0; font->dpi= 0; font->size= 0; - font->kerning= 0.0f; font->cache.first= NULL; font->cache.last= NULL; font->glyph_cache= NULL; |