From 523bc981cfeecead5050e7af44bbe252c166d718 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 27 Aug 2021 13:09:33 +1000 Subject: [PATCH] Fix loading packed fonts for sequencer strips --- source/blender/sequencer/intern/effects.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index 9235da366f4..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" @@ -3782,12 +3783,23 @@ void SEQ_effect_text_font_load(TextVars *data, const bool do_id_user) id_us_plus(&vfont->id); } - char path[FILE_MAX]; - STRNCPY(path, vfont->filepath); - BLI_assert(BLI_thread_is_main()); - BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&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(path); + data->text_blf_id = BLF_load_mem(name, pf->data, pf->size); + } + else { + char path[FILE_MAX]; + STRNCPY(path, vfont->filepath); + BLI_assert(BLI_thread_is_main()); + BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id)); + + data->text_blf_id = BLF_load(path); + } } static void free_text_effect(Sequence *seq, const bool do_id_user)