Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/sequencer/intern/effects.c')
-rw-r--r--source/blender/sequencer/intern/effects.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c
index d4adad9a34d..37bac523645 100644
--- a/source/blender/sequencer/intern/effects.c
+++ b/source/blender/sequencer/intern/effects.c
@@ -39,6 +39,7 @@
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
+#include "DNA_packedFile_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_space_types.h"
@@ -3755,31 +3756,47 @@ static void init_text_effect(Sequence *seq)
void SEQ_effect_text_font_unload(TextVars *data, const bool do_id_user)
{
- if (data) {
- /* Unlink the VFont */
- if (do_id_user && data->text_font != NULL) {
- id_us_min(&data->text_font->id);
- data->text_font = NULL;
- }
+ if (data == NULL) {
+ return;
+ }
- /* Unload the BLF font. */
- if (data->text_blf_id >= 0) {
- BLF_unload_id(data->text_blf_id);
- }
+ /* Unlink the VFont */
+ if (do_id_user && data->text_font != NULL) {
+ id_us_min(&data->text_font->id);
+ data->text_font = NULL;
+ }
+
+ /* Unload the BLF font. */
+ if (data->text_blf_id >= 0) {
+ BLF_unload_id(data->text_blf_id);
}
}
void SEQ_effect_text_font_load(TextVars *data, const bool do_id_user)
{
- if (data->text_font != NULL) {
- if (do_id_user) {
- id_us_plus(&data->text_font->id);
- }
+ VFont *vfont = data->text_font;
+ if (vfont == NULL) {
+ return;
+ }
+
+ if (do_id_user) {
+ id_us_plus(&vfont->id);
+ }
+ if (vfont->packedfile != NULL) {
+ PackedFile *pf = vfont->packedfile;
+ /* Create a name that's unique between library data-blocks to avoid loading
+ * a font per strip which will load fonts many times. */
+ char name[MAX_ID_FULL_NAME];
+ BKE_id_full_name_get(name, &vfont->id, 0);
+
+ data->text_blf_id = BLF_load_mem(name, pf->data, pf->size);
+ }
+ else {
char path[FILE_MAX];
- STRNCPY(path, data->text_font->filepath);
+ STRNCPY(path, vfont->filepath);
BLI_assert(BLI_thread_is_main());
- BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&data->text_font->id));
+ BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
data->text_blf_id = BLF_load(path);
}
@@ -3850,9 +3867,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
if (data->text_blf_id == SEQ_FONT_NOT_LOADED) {
data->text_blf_id = -1;
- if (data->text_font) {
- data->text_blf_id = BLF_load(data->text_font->filepath);
- }
+ SEQ_effect_text_font_load(data, false);
}
if (data->text_blf_id >= 0) {