diff --git a/source/blender/blenfont/BLF_api.hh b/source/blender/blenfont/BLF_api.hh index efea4ac9c41..b64103083f9 100644 --- a/source/blender/blenfont/BLF_api.hh +++ b/source/blender/blenfont/BLF_api.hh @@ -420,6 +420,9 @@ enum { * \note Can be checked without checking #BLF_MONOSPACED which can be assumed to be disabled. */ BLF_RENDER_SUBPIXELAA = 1 << 18, + + /* Do not look in other fonts when a glyph is not found in this font. */ + BLF_NO_FALLBACK = 1 << 19, }; #define BLF_DRAW_STR_DUMMY_MAX 1024 diff --git a/source/blender/blenfont/intern/blf_glyph.cc b/source/blender/blenfont/intern/blf_glyph.cc index ecbcf2b5b4d..338a858c545 100644 --- a/source/blender/blenfont/intern/blf_glyph.cc +++ b/source/blender/blenfont/intern/blf_glyph.cc @@ -787,8 +787,8 @@ static FT_UInt blf_glyph_index_from_charcode(FontBLF **font, const uint charcode return glyph_index; } - /* Only fonts managed by the cache can fallback. */ - if (!((*font)->flags & BLF_CACHED)) { + /* Fonts managed by the cache can fallback. Unless specifically forbidden. */ + if (!((*font)->flags & BLF_CACHED) || ((*font)->flags & BLF_NO_FALLBACK)) { return 0; } diff --git a/source/blender/sequencer/intern/effects/vse_effect_text.cc b/source/blender/sequencer/intern/effects/vse_effect_text.cc index a38da3c2fe4..8e2dbfa493e 100644 --- a/source/blender/sequencer/intern/effects/vse_effect_text.cc +++ b/source/blender/sequencer/intern/effects/vse_effect_text.cc @@ -553,6 +553,11 @@ namespace blender::seq { static void text_draw(const TextVarsRuntime *runtime, float color[4]) { + const bool use_fallback = (runtime->font <= 1); + if (!use_fallback) { + BLF_enable(runtime->font, BLF_NO_FALLBACK); + } + for (const LineInfo &line : runtime->lines) { for (const CharInfo &character : line.characters) { BLF_position(runtime->font, character.position.x, character.position.y, 0.0f); @@ -560,6 +565,10 @@ static void text_draw(const TextVarsRuntime *runtime, float color[4]) BLF_draw_buffer(runtime->font, character.str_ptr, character.byte_length); } } + + if (!use_fallback) { + BLF_disable(runtime->font, BLF_NO_FALLBACK); + } } static rcti draw_text_outline(const SeqRenderData *context, @@ -805,6 +814,12 @@ static blender::Vector build_character_info(const TextVars *data, int const size_t len_max = BLI_strnlen(data->text, sizeof(data->text)); int byte_offset = 0; int char_index = 0; + + const bool use_fallback = (font <= 1); + if (!use_fallback) { + BLF_enable(font, BLF_NO_FALLBACK); + } + while (byte_offset <= len_max) { const char *str = data->text + byte_offset; const int char_length = BLI_str_utf8_size_safe(str); @@ -819,6 +834,11 @@ static blender::Vector build_character_info(const TextVars *data, int byte_offset += char_length; char_index++; } + + if (!use_fallback) { + BLF_disable(font, BLF_NO_FALLBACK); + } + return characters; }