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/intern/blf.c | |
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/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 25 |
1 files changed, 20 insertions, 5 deletions
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; + } } } |