diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-01 18:12:56 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-01 20:42:56 +0300 |
commit | 2d8880643dad51f09370851248d3d6d80b5bf6d9 (patch) | |
tree | cf9529064c9cebad1b7013ecc8f3c0983cf27b44 /source/blender/blenfont/intern/blf_font.c | |
parent | 7173069cbe76b69b5800cee91a25cee6cb2a9586 (diff) |
Font Preview: fallback to default english strings in case translated ones have not enough chars in current font.
This avoids some ugly 'missing char' in previews - not all cases of course, but most common ones.
A complete solution would be much much more involved, and probably not worth it here.
Definitively not before a release, at least!
Diffstat (limited to 'source/blender/blenfont/intern/blf_font.c')
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 1391e18748c..8f8ee445ef9 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -667,6 +667,28 @@ float blf_font_fixed_width(FontBLF *font) return g->advance; } +int blf_font_count_missing_chars(FontBLF *font, const char *str, const size_t len, int *r_tot_chars) +{ + int missing = 0; + size_t i = 0; + + *r_tot_chars = 0; + while (i < len) { + unsigned int c; + + if ((c = str[i]) < 0x80) { + i++; + } + else if ((c = BLI_str_utf8_as_unicode_step(str, &i)) != BLI_UTF8_ERR) { + if (FT_Get_Char_Index((font)->face, c) == 0) { + missing++; + } + } + (*r_tot_chars)++; + } + return missing; +} + void blf_font_free(FontBLF *font) { GlyphCacheBLF *gc; |