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:
committed by
Harley Acheson
parent
b4a355b30d
commit
972c0b9463
Binary file not shown.
@@ -1985,7 +1985,6 @@ struct FaceDetails {
|
|||||||
|
|
||||||
/* Details about the fallback fonts we ship, so that we can load only when needed. */
|
/* Details about the fallback fonts we ship, so that we can load only when needed. */
|
||||||
static const FaceDetails static_face_details[] = {
|
static const FaceDetails static_face_details[] = {
|
||||||
{"lastresort.woff2", UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX},
|
|
||||||
{"Noto Sans CJK Regular.woff2",
|
{"Noto Sans CJK Regular.woff2",
|
||||||
0,
|
0,
|
||||||
TT_UCR_CJK_SYMBOLS | TT_UCR_HIRAGANA | TT_UCR_KATAKANA | TT_UCR_BOPOMOFO | TT_UCR_CJK_MISC |
|
TT_UCR_CJK_SYMBOLS | TT_UCR_HIRAGANA | TT_UCR_KATAKANA | TT_UCR_BOPOMOFO | TT_UCR_CJK_MISC |
|
||||||
|
|||||||
@@ -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. */
|
/* Next look in the rest. */
|
||||||
FontBLF *last_resort = nullptr;
|
|
||||||
for (int i = 0; i < BLF_MAX_FONT; i++) {
|
for (int i = 0; i < BLF_MAX_FONT; i++) {
|
||||||
FontBLF *f = global_font[i];
|
FontBLF *f = global_font[i];
|
||||||
if (!f || f == *font || !(f->flags & BLF_DEFAULT)) {
|
if (!f || f == *font || !(f->flags & BLF_DEFAULT)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (f->flags & BLF_LAST_RESORT) {
|
|
||||||
last_resort = f;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (coverage_bit >= 0 && !blf_font_has_coverage_bit(f, coverage_bit)) {
|
if (coverage_bit >= 0 && !blf_font_has_coverage_bit(f, coverage_bit)) {
|
||||||
glyph_index = blf_get_char_index(f, charcode);
|
glyph_index = blf_get_char_index(f, charcode);
|
||||||
if (glyph_index) {
|
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);
|
printf("Unicode character U+%04X not found in loaded fonts. \n", charcode);
|
||||||
#endif
|
#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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1370,6 +1356,11 @@ GlyphBLF *blf_glyph_ensure(FontBLF *font, GlyphCacheBLF *gc, const uint charcode
|
|||||||
FontBLF *font_with_glyph = font;
|
FontBLF *font_with_glyph = font;
|
||||||
FT_UInt glyph_index = blf_glyph_index_from_charcode(&font_with_glyph, charcode);
|
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)) {
|
if (!blf_ensure_face(font_with_glyph)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ GlyphBLF *blf_glyph_ensure_icon(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a character's outlines into curves.
|
* Convert a character's outlines into curves.
|
||||||
|
* \return success if the character was found and converted.
|
||||||
*/
|
*/
|
||||||
bool blf_character_to_curves(FontBLF *font,
|
bool blf_character_to_curves(FontBLF *font,
|
||||||
unsigned int unicode,
|
unsigned int unicode,
|
||||||
|
|||||||
BIN
tests/files/sequence_editing/effects/reference/text_long_string.png
(Stored with Git LFS)
BIN
tests/files/sequence_editing/effects/reference/text_long_string.png
(Stored with Git LFS)
Binary file not shown.
Reference in New Issue
Block a user