Commit: f8c52402d6c76392444a9dd9ab90d2f48b1a03fe
Author: Campbell Barton
Date:   Tue Jan 20 14:50:56 2015 +1100
Branches: master
https://developer.blender.org/rBf8c52402d6c76392444a9dd9ab90d2f48b1a03fe

BLF: remove paranoid checks for unset default font

===================================================================

M       source/blender/blenfont/intern/blf.c
M       source/blender/editors/interface/interface_style.c

===================================================================

diff --git a/source/blender/blenfont/intern/blf.c 
b/source/blender/blenfont/intern/blf.c
index cdccbe0..6bbf071 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 8b2ce90..dda4220 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__);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to