diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-18 13:48:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-18 13:48:09 +0400 |
commit | 249b41762a98b5e357cc32e0ba0cb673fc0c6225 (patch) | |
tree | 0791b0e9b437817b4495d086356c22438ce837e5 /source/blender/blenfont/intern/blf.c | |
parent | 7da6e0c82e2deac0bf177d8a273dc217202b3659 (diff) |
blf code - no functional changes.
- remove saniy checks from blf_font.c, the callers now check instead.
- move duplicate code into defines (may move into static functions).
- move kerning checks into const values set at the start of the function, rather then checking on every character.
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 577697de594..07291fbb3e3 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -505,7 +505,7 @@ static void blf_draw__end(void) void BLF_draw(int fontid, const char *str, size_t len) { FontBLF *font= BLF_get(fontid); - if (font) { + if (font && font->glyph_cache) { blf_draw__start(font); blf_font_draw(font, str, len); blf_draw__end(); @@ -515,7 +515,7 @@ void BLF_draw(int fontid, const char *str, size_t len) void BLF_draw_ascii(int fontid, const char *str, size_t len) { FontBLF *font= BLF_get(fontid); - if (font) { + if (font && font->glyph_cache) { blf_draw__start(font); blf_font_draw_ascii(font, str, len); blf_draw__end(); @@ -536,7 +536,7 @@ void BLF_width_and_height(int fontid, const char *str, float *width, float *heig FontBLF *font; font= BLF_get(fontid); - if (font) + if (font && font->glyph_cache) blf_font_width_and_height(font, str, width, height); } @@ -545,7 +545,7 @@ float BLF_width(int fontid, const char *str) FontBLF *font; font= BLF_get(fontid); - if (font) + if (font && font->glyph_cache) return(blf_font_width(font, str)); return(0.0f); } @@ -555,9 +555,9 @@ float BLF_fixed_width(int fontid) FontBLF *font; font= BLF_get(fontid); - if (font) - return(blf_font_fixed_width(font)); - return(0.0f); + if (font && font->glyph_cache) + return blf_font_fixed_width(font); + return 0.0f; } float BLF_width_default(const char *str) @@ -582,7 +582,7 @@ float BLF_height(int fontid, const char *str) FontBLF *font; font= BLF_get(fontid); - if (font) + if (font && font->glyph_cache) return(blf_font_height(font, str)); return(0.0f); } @@ -592,10 +592,8 @@ float BLF_height_max(int fontid) FontBLF *font; font= BLF_get(fontid); - if (font) { - if(font->glyph_cache) - return(font->glyph_cache->max_glyph_height); - } + if (font && font->glyph_cache) + return(font->glyph_cache->max_glyph_height); return(0.0f); } @@ -741,9 +739,8 @@ void BLF_buffer_col(int fontid, float r, float g, float b, float a) void BLF_draw_buffer(int fontid, const char *str) { - FontBLF *font; - - font= BLF_get(fontid); - if (font) + FontBLF *font= BLF_get(fontid); + if (font && font->glyph_cache && (font->b_fbuf || font->b_cbuf)) { blf_font_buffer(font, str); + } } |