Fix: Use Font Flag to Identify Default Fonts

with #133413 the intent was that VSE Text strips would not use the
fallback font stack if using a custom (non-default) font. However this
determination was done by comparing the font id. This was very weak as
the id can vary quite a bit within the first few fonts. This PR instead
adds a BLF function (BLF_is_builtin) that uses BLF_DEFAULT font flag
instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/135014
This commit is contained in:
Harley Acheson
2025-02-23 22:41:08 +01:00
committed by Harley Acheson
parent 12b1f8bd7a
commit 89f61ee6cb
3 changed files with 13 additions and 2 deletions

View File

@@ -318,6 +318,11 @@ blender::Vector<blender::StringRef> BLF_string_wrap(int fontid,
void BLF_enable(int fontid, int option);
void BLF_disable(int fontid, int option);
/**
* Is this font part of the default fonts in the fallback stack?
*/
bool BLF_is_builtin(int fontid);
/**
* Note that shadow needs to be enabled with #BLF_enable.
*/

View File

@@ -336,6 +336,12 @@ void BLF_disable(int fontid, int option)
}
}
bool BLF_is_builtin(int fontid)
{
FontBLF *font = blf_get(fontid);
return font ? (font->flags & BLF_DEFAULT) : false;
}
void BLF_character_weight(int fontid, int weight)
{
FontBLF *font = blf_get(fontid);

View File

@@ -552,7 +552,7 @@ namespace blender::seq {
static void text_draw(const TextVarsRuntime *runtime, float color[4])
{
const bool use_fallback = (runtime->font <= 1);
const bool use_fallback = BLF_is_builtin(runtime->font);
if (!use_fallback) {
BLF_enable(runtime->font, BLF_NO_FALLBACK);
}
@@ -814,7 +814,7 @@ static blender::Vector<CharInfo> build_character_info(const TextVars *data, int
int byte_offset = 0;
int char_index = 0;
const bool use_fallback = (font <= 1);
const bool use_fallback = BLF_is_builtin(font);
if (!use_fallback) {
BLF_enable(font, BLF_NO_FALLBACK);
}