UI: BLF Use Custom NotDef Not Last Resort

This PR removes the "Last Resort" font from the stack. Instead uses a
custom "not def" glyph, defined as an SVG file. This glyph is shown
when requesting a character not found for text inputs, text editor, and
for Sequencer text strips.

Pull Request: https://projects.blender.org/blender/blender/pulls/132032
This commit is contained in:
Harley Acheson
2025-07-31 19:53:29 +02:00
committed by Harley Acheson
parent b4a355b30d
commit 972c0b9463
5 changed files with 9 additions and 18 deletions

View File

@@ -1985,7 +1985,6 @@ struct FaceDetails {
/* Details about the fallback fonts we ship, so that we can load only when needed. */
static const FaceDetails static_face_details[] = {
{"lastresort.woff2", UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX},
{"Noto Sans CJK Regular.woff2",
0,
TT_UCR_CJK_SYMBOLS | TT_UCR_HIRAGANA | TT_UCR_KATAKANA | TT_UCR_BOPOMOFO | TT_UCR_CJK_MISC |

View File

@@ -811,17 +811,12 @@ static FT_UInt blf_glyph_index_from_charcode(FontBLF **font, const uint charcode
}
}
/* Next look in the rest. Also check if we have a last-resort font. */
FontBLF *last_resort = nullptr;
/* Next look in the rest. */
for (int i = 0; i < BLF_MAX_FONT; i++) {
FontBLF *f = global_font[i];
if (!f || f == *font || !(f->flags & BLF_DEFAULT)) {
continue;
}
if (f->flags & BLF_LAST_RESORT) {
last_resort = f;
continue;
}
if (coverage_bit >= 0 && !blf_font_has_coverage_bit(f, coverage_bit)) {
glyph_index = blf_get_char_index(f, charcode);
if (glyph_index) {
@@ -835,15 +830,6 @@ static FT_UInt blf_glyph_index_from_charcode(FontBLF **font, const uint charcode
printf("Unicode character U+%04X not found in loaded fonts. \n", charcode);
#endif
/* Not found in the stack, return from Last Resort if there is one. */
if (last_resort) {
glyph_index = blf_get_char_index(last_resort, charcode);
if (glyph_index) {
*font = last_resort;
return glyph_index;
}
}
return 0;
}
@@ -1370,6 +1356,11 @@ GlyphBLF *blf_glyph_ensure(FontBLF *font, GlyphCacheBLF *gc, const uint charcode
FontBLF *font_with_glyph = font;
FT_UInt glyph_index = blf_glyph_index_from_charcode(&font_with_glyph, charcode);
if (!glyph_index) {
/* 1 = id of ICON_CHAR_NOTDEF */
return blf_glyph_ensure_icon(gc, 1, false, nullptr);
}
if (!blf_ensure_face(font_with_glyph)) {
return nullptr;
}

View File

@@ -202,6 +202,7 @@ GlyphBLF *blf_glyph_ensure_icon(
/**
* Convert a character's outlines into curves.
* \return success if the character was found and converted.
*/
bool blf_character_to_curves(FontBLF *font,
unsigned int unicode,

Binary file not shown.