From 26ea1f42c34c80830aafaf395c8c43f0df6e69cb Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 4 Jul 2024 20:18:06 +0200 Subject: [PATCH] Fix #122808: Use Default Font when Vfont Missing For text objects, current code will use another font if you ask for a character that is not found in the selected font. But what if the selected font is invalid? This can happen with a saved Blend that uses a non-packed font that is since deleted. Current behavior will show nothing. This PR restores earlier behavior where we use the built-in font in this case. This does not make any changes to error reporting. Pull Request: https://projects.blender.org/blender/blender/pulls/124184 --- source/blender/blenkernel/intern/vfontdata_freetype.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.cc b/source/blender/blenkernel/intern/vfontdata_freetype.cc index 0f83986a078..6cfa1ebc212 100644 --- a/source/blender/blenkernel/intern/vfontdata_freetype.cc +++ b/source/blender/blenkernel/intern/vfontdata_freetype.cc @@ -93,7 +93,10 @@ VChar *BKE_vfontdata_char_from_freetypefont(VFont *vfont, ulong character) } if (font_id == -1) { - return nullptr; + /* This could happen for a saved file with an unpacked local font that was + * later removed. Load the default UI font so we can still show _something_. */ + font_id = BLF_load_mem( + vfont->data->name, static_cast(builtin_font_data), builtin_font_size); } VChar *che = (VChar *)MEM_callocN(sizeof(VChar), "objfnt_char");