Fix: Handle Missing Font in ID List Previews #124111

Merged
Harley Acheson merged 1 commits from Harley/blender:IDListPreviewMissingFont into main 2024-07-03 18:24:43 +02:00
2 changed files with 10 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#include "DNA_userdef_types.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_math_color.h"
#include "BLI_math_vector.h"
@ -1724,6 +1725,12 @@ static void ui_tooltip_from_vfont(VFont &font, uiTooltipData &data)
return;
}
if (!BLI_exists(font.filepath)) {
UI_tooltip_text_field_add(
&data, TIP_("File not found"), {}, UI_TIP_STYLE_NORMAL, UI_TIP_LC_ALERT);
return;
}
float color[4];
const uiWidgetColors *theme = ui_tooltip_get_theme();
rgba_uchar_to_float(color, theme->text);

View File

@ -49,6 +49,9 @@ bool IMB_thumb_load_font_get_hash(char *r_hash)
ImBuf *IMB_font_preview(const char *filepath, uint width, const float color[4])
{
int font_id = (filepath[0] != '<') ? BLF_load(filepath) : 0;
if (font_id == -1) {
return nullptr;
}
const char sample[] = "ABCDEFGH\nabcdefg123";
BLF_buffer_col(font_id, color);