From 524a9e3db8102c89abf3b80cddaea60c314d67ae Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 17 Jun 2022 10:30:34 -0700 Subject: BLF: Fallback Font Stack Allow use of multiple fonts acting together like a fallback stack, where if a glyph is not found in one it can be retrieved from another. See D12622 for much more detail Differential Revision: https://developer.blender.org/D12622 Reviewed by Brecht Van Lommel --- source/blender/editors/interface/interface_style.cc | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'source/blender/editors/interface/interface_style.cc') diff --git a/source/blender/editors/interface/interface_style.cc b/source/blender/editors/interface/interface_style.cc index 291ede05730..904765f6dc4 100644 --- a/source/blender/editors/interface/interface_style.cc +++ b/source/blender/editors/interface/interface_style.cc @@ -382,19 +382,8 @@ void uiStyleInit(void) } CLAMP(U.dpi, 48, 144); - LISTBASE_FOREACH (uiFont *, font, &U.uifonts) { - BLF_unload_id(font->blf_id); - } - - if (blf_mono_font != -1) { - BLF_unload_id(blf_mono_font); - blf_mono_font = -1; - } - - if (blf_mono_font_render != -1) { - BLF_unload_id(blf_mono_font_render); - blf_mono_font_render = -1; - } + /* Needed so that custom fonts are always first. */ + BLF_unload_all(); uiFont *font_first = static_cast(U.uifonts.first); @@ -498,6 +487,9 @@ void uiStyleInit(void) const bool unique = true; blf_mono_font_render = BLF_load_mono_default(unique); } + + /* Load the fallback fonts last. */ + BLF_load_font_stack(); } void UI_fontstyle_set(const uiFontStyle *fs) -- cgit v1.2.3