diff options
author | Diego Borghetti <bdiego@gmail.com> | 2009-07-11 02:16:25 +0400 |
---|---|---|
committer | Diego Borghetti <bdiego@gmail.com> | 2009-07-11 02:16:25 +0400 |
commit | b80b581bc03b6df28bd3a10118d85b78d5ca011b (patch) | |
tree | 2294f8ee5407651014c9ce873853276277857595 /source/blender/blenfont | |
parent | 395025d67ec9374039703d591d6d44b664f79dcd (diff) |
Allow the user set which style to use for the kerning value.
This are freetype2 options:
Unfitted - Scaled but un-grid-fitted kerning distances
Default - Scaled and grid-fitted kerning distances
We always use Unfitted, but the "Default" style give better result here,
so please test and if nobody complain we can set this style as the default.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 1 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 20 |
2 files changed, 15 insertions, 6 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 53f108f87eb..99934a80143 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -137,6 +137,7 @@ void BLF_dir_free(char **dirs, int count); #define BLF_ROTATION (1<<0) #define BLF_CLIPPING (1<<1) #define BLF_SHADOW (1<<2) +#define BLF_KERNING_DEFAULT (1<<3) /* font->mode. */ #define BLF_MODE_TEXTURE 0 diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 989746ca501..affc35ea11e 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -102,7 +102,7 @@ void blf_font_draw(FontBLF *font, char *str) FT_Vector delta; FT_UInt glyph_index, g_prev_index; int pen_x, pen_y; - int i, has_kerning; + int i, has_kerning, st; if (!font->glyph_cache) return; @@ -143,9 +143,13 @@ void blf_font_draw(FontBLF *font, char *str) delta.x= 0; delta.y= 0; - if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { + 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 (st == 0) pen_x += delta.x >> 6; - } } /* do not return this loop if clipped, we want every character tested */ @@ -165,7 +169,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) FT_UInt glyph_index, g_prev_index; rctf gbox; int pen_x, pen_y; - int i, has_kerning; + int i, has_kerning, st; if (!font->glyph_cache) return; @@ -211,9 +215,13 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) delta.x= 0; delta.y= 0; - if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { + 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 (st == 0) pen_x += delta.x >> 6; - } } gbox.xmin= g->box.xmin + pen_x; |