diff options
author | Richard Antalik <richardantalik@gmail.com> | 2019-01-14 08:28:07 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2019-01-14 08:57:09 +0300 |
commit | b3dbe17658fe8ca5115abab642cc0f1680d1f0d5 (patch) | |
tree | 9ee5fa8e6f8e4e8a009a9f6ed4bb2af0f91693f8 /source/blender/blenfont | |
parent | c450461e68cdd723825c7bf4a4ebde079ba7b57b (diff) |
Add font selection to VSE text strips
Allows users to select a font for text strips in the video sequence editor.
Related: 3610f1fc43d0 Sequencer: refactor clipboard copy to no longer increase user count.
Reviewed by: Brecht
Differential Revision: https://developer.blender.org/D3621
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 1 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 25 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_internal_types.h | 3 |
3 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 8a3728574f3..75afa0e3018 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -51,6 +51,7 @@ void BLF_batch_reset(void); /* call when changing opengl context. */ void BLF_cache_clear(void); +/* Loads a font, or returns an already loaded font and increments its reference count. */ int BLF_load(const char *name) ATTR_NONNULL(); int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL(); diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 70a7b862830..70478fd1d1c 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -198,7 +198,8 @@ int BLF_load(const char *name) /* check if we already load this font. */ i = blf_search(name); if (i >= 0) { - /*font = global_font[i];*/ /*UNUSED*/ + font = global_font[i]; + font->reference_count++; return i; } @@ -222,6 +223,7 @@ int BLF_load(const char *name) return -1; } + font->reference_count = 1; global_font[i] = font; return i; } @@ -255,6 +257,7 @@ int BLF_load_unique(const char *name) return -1; } + font->reference_count = 1; global_font[i] = font; return i; } @@ -296,6 +299,7 @@ int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) return -1; } + font->reference_count = 1; global_font[i] = font; return i; } @@ -326,6 +330,7 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size return -1; } + font->reference_count = 1; global_font[i] = font; return i; } @@ -339,8 +344,13 @@ void BLF_unload(const char *name) font = global_font[i]; if (font && (STREQ(font->name, name))) { - blf_font_free(font); - global_font[i] = NULL; + BLI_assert(font->reference_count > 0); + font->reference_count--; + + if (font->reference_count == 0) { + blf_font_free(font); + global_font[i] = NULL; + } } } } @@ -349,8 +359,13 @@ void BLF_unload_id(int fontid) { FontBLF *font = blf_get(fontid); if (font) { - blf_font_free(font); - global_font[fontid] = NULL; + BLI_assert(font->reference_count > 0); + font->reference_count--; + + if (font->reference_count == 0) { + blf_font_free(font); + global_font[fontid] = NULL; + } } } diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 265835f4c75..14bc081cd10 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -194,6 +194,9 @@ typedef struct FontBLF { /* font name. */ char *name; + /* # of times this font was loaded */ + unsigned int reference_count; + /* filename or NULL. */ char *filename; |