diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2022-06-17 20:30:34 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2022-06-17 20:31:48 +0300 |
commit | 524a9e3db8102c89abf3b80cddaea60c314d67ae (patch) | |
tree | eae881aad7e3b114dbdfb5cbac183355a38b5d06 /source/blender/blenfont/intern/blf.c | |
parent | 5485057a27b92400ddc57dfb67c1017f26fefad8 (diff) |
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
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index a944ab332bd..a1fcc17ca3f 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -34,13 +34,6 @@ #include "blf_internal.h" #include "blf_internal_types.h" -/* Max number of font in memory. - * Take care that now every font have a glyph cache per size/dpi, - * so we don't need load the same font with different size, just - * load one and call BLF_size. - */ -#define BLF_MAX_FONT 16 - #define BLF_RESULT_CHECK_INIT(r_info) \ if (r_info) { \ memset(r_info, 0, sizeof(*(r_info))); \ @@ -48,7 +41,7 @@ ((void)0) /* Font array. */ -static FontBLF *global_font[BLF_MAX_FONT] = {NULL}; +FontBLF *global_font[BLF_MAX_FONT] = {NULL}; /* XXX: should these be made into global_font_'s too? */ @@ -134,6 +127,11 @@ bool BLF_has_glyph(int fontid, unsigned int unicode) return false; } +bool BLF_is_loaded(const char *name) +{ + return blf_search(name) >= 0; +} + int BLF_load(const char *name) { /* check if we already load this font. */ @@ -255,6 +253,20 @@ void BLF_unload_id(int fontid) } } +void BLF_unload_all(void) +{ + for (int i = 0; i < BLF_MAX_FONT; i++) { + FontBLF *font = global_font[i]; + if (font) { + blf_font_free(font); + global_font[i] = NULL; + } + } + blf_mono_font = -1; + blf_mono_font_render = -1; + BLF_default_set(-1); +} + void BLF_enable(int fontid, int option) { FontBLF *font = blf_get(fontid); |