From 19dcd32ee5942d17f9b9d45d7e13fd06206f54b8 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Mon, 12 Oct 2020 09:53:00 -0700 Subject: UI: Remove Hard-coded Default Font Size Default text output routines (which do not specify a size) will now use Text Style point size. Differential Revision: https://developer.blender.org/D9107 Reviewed by Brecht Van Lommel --- source/blender/blenfont/BLF_api.h | 5 +++++ source/blender/blenfont/intern/blf.c | 24 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index bf84f5c57b3..17a650e28f5 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -163,8 +163,13 @@ float BLF_height_ex(int fontid, const char *str, size_t len, struct ResultBLF *r float BLF_height(int fontid, const char *str, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); /* Return dimensions of the font without any sample text. */ + int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT; +int BLF_default_height_max(void) ATTR_WARN_UNUSED_RESULT; + float BLF_width_max(int fontid) ATTR_WARN_UNUSED_RESULT; +float BLF_default_width_max(void) ATTR_WARN_UNUSED_RESULT; + float BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT; float BLF_ascender(int fontid) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 3163b633df2..76ff498f5c2 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -38,6 +38,7 @@ #include "MEM_guardedalloc.h" #include "DNA_listBase.h" +#include "DNA_userdef_types.h" #include "DNA_vec_types.h" #include "BLI_math.h" @@ -47,6 +48,8 @@ #include "IMB_colormanagement.h" +#include "UI_interface.h" + #include "GPU_immediate.h" #include "GPU_matrix.h" #include "GPU_shader.h" @@ -75,7 +78,6 @@ static FontBLF *global_font[BLF_MAX_FONT] = {NULL}; /* Default size and dpi, for BLF_draw_default. */ static int global_font_default = -1; -static int global_font_points = 11; static int global_font_dpi = 72; /* XXX, should these be made into global_font_'s too? */ @@ -96,7 +98,6 @@ int BLF_init(void) global_font[i] = NULL; } - global_font_points = 11; global_font_dpi = 72; return blf_font_init(); @@ -518,7 +519,8 @@ void BLF_draw_default(float x, float y, float z, const char *str, size_t len) { ASSERT_DEFAULT_SET; - BLF_size(global_font_default, global_font_points, global_font_dpi); + const uiStyle *style = UI_style_get(); + BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi); BLF_position(global_font_default, x, y, z); BLF_draw(global_font_default, str, len); } @@ -528,7 +530,8 @@ void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t l { ASSERT_DEFAULT_SET; - BLF_size(global_font_default, global_font_points, global_font_dpi); + const uiStyle *style = UI_style_get(); + BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi); BLF_position(global_font_default, x, y, z); BLF_draw_ascii(global_font_default, str, len); /* XXX, use real length */ } @@ -537,7 +540,8 @@ int BLF_set_default(void) { ASSERT_DEFAULT_SET; - BLF_size(global_font_default, global_font_points, global_font_dpi); + const uiStyle *style = UI_style_get(); + BLF_size(global_font_default, style->widgetlabel.points, global_font_dpi); return global_font_default; } @@ -820,6 +824,11 @@ int BLF_height_max(int fontid) return 0; } +int BLF_default_height_max(void) +{ + return BLF_height_max(global_font_default); +} + float BLF_width_max(int fontid) { FontBLF *font = blf_get(fontid); @@ -831,6 +840,11 @@ float BLF_width_max(int fontid) return 0.0f; } +float BLF_default_width_max(void) +{ + return BLF_width_max(global_font_default); +} + float BLF_descender(int fontid) { FontBLF *font = blf_get(fontid); -- cgit v1.2.3