diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-20 06:50:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-20 07:50:20 +0300 |
commit | f8c52402d6c76392444a9dd9ab90d2f48b1a03fe (patch) | |
tree | 88c1e0ab71cf982867da29e19f5b6a61f02769d1 /source/blender | |
parent | a1f4821b94b09572d1606e4268b88e62bd5dd1e7 (diff) |
BLF: remove paranoid checks for unset default font
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 35 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 5 |
2 files changed, 10 insertions, 30 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index cdccbe044bb..6bbf07173b9 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -63,6 +63,9 @@ */ #define BLF_MAX_FONT 16 +/* call BLF_default_set first! */ +#define ASSERT_DEFAULT_SET BLI_assert(global_font_default != -1) + /* Font array. */ static FontBLF *global_font[BLF_MAX_FONT] = {NULL}; @@ -160,21 +163,6 @@ void BLF_default_set(int fontid) } } -static int blf_global_font_init(void) -{ - if (global_font_default == -1) { - global_font_default = blf_search("default"); - } - - if (global_font_default == -1) { - printf("Warning: Can't find default font!\n"); - return 0; - } - else { - return 1; - } -} - int BLF_load(const char *name) { FontBLF *font; @@ -477,8 +465,7 @@ void BLF_blur(int fontid, int size) void BLF_draw_default(float x, float y, float z, const char *str, size_t len) { - if (!blf_global_font_init()) - return; + ASSERT_DEFAULT_SET; BLF_size(global_font_default, global_font_points, global_font_dpi); BLF_position(global_font_default, x, y, z); @@ -488,8 +475,7 @@ void BLF_draw_default(float x, float y, float z, const char *str, size_t len) /* same as above but call 'BLF_draw_ascii' */ void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len) { - if (!blf_global_font_init()) - return; + ASSERT_DEFAULT_SET; BLF_size(global_font_default, global_font_points, global_font_dpi); BLF_position(global_font_default, x, y, z); @@ -670,10 +656,7 @@ void BLF_width_and_height(int fontid, const char *str, size_t len, float *r_widt void BLF_width_and_height_default(const char *str, size_t len, float *r_width, float *r_height) { - if (!blf_global_font_init()) { - *r_width = *r_height = 0.0f; - return; - } + ASSERT_DEFAULT_SET; BLF_size(global_font_default, global_font_points, global_font_dpi); BLF_width_and_height(global_font_default, str, len, r_width, r_height); @@ -703,8 +686,7 @@ float BLF_fixed_width(int fontid) float BLF_width_default(const char *str, size_t len) { - if (!blf_global_font_init()) - return 0.0f; + ASSERT_DEFAULT_SET; BLF_size(global_font_default, global_font_points, global_font_dpi); return BLF_width(global_font_default, str, len); @@ -767,8 +749,7 @@ float BLF_ascender(int fontid) float BLF_height_default(const char *str, size_t len) { - if (!blf_global_font_init()) - return 0.0f; + ASSERT_DEFAULT_SET; BLF_size(global_font_default, global_font_points, global_font_dpi); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 8b2ce90dcf5..dda4220bf18 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -398,11 +398,10 @@ void uiStyleInit(void) if (font->blf_id == -1) { font->blf_id = BLF_load_mem("default", (unsigned char *)datatoc_bfont_ttf, datatoc_bfont_ttf_size); } - else { - BLF_default_set(font->blf_id); - } } + BLF_default_set(font->blf_id); + if (font->blf_id == -1) { if (G.debug & G_DEBUG) printf("%s: error, no fonts available\n", __func__); |