mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-10 12:06:28 +00:00
Fonts: Added a ImFontFlags_NoLoadError flag to let user code try file paths. (3611)
This commit is contained in:
1
imgui.h
1
imgui.h
@@ -3676,6 +3676,7 @@ enum ImFontFlags_
|
|||||||
ImFontFlags_None = 0,
|
ImFontFlags_None = 0,
|
||||||
ImFontFlags_LockBakedSizes = 1 << 0, // Disable loading new baked sizes, disable garbage collecting current ones. e.g. if you want to lock a font to a single size.
|
ImFontFlags_LockBakedSizes = 1 << 0, // Disable loading new baked sizes, disable garbage collecting current ones. e.g. if you want to lock a font to a single size.
|
||||||
ImFontFlags_NoLoadGlyphs = 1 << 1, // Disable loading new glyphs.
|
ImFontFlags_NoLoadGlyphs = 1 << 1, // Disable loading new glyphs.
|
||||||
|
ImFontFlags_NoLoadError = 1 << 2, // Disable throwing an error/assert when calling AddFontXXX() with missing file/data. Calling code is expected to check AddFontXXX() return value.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Font runtime data and rendering
|
// Font runtime data and rendering
|
||||||
|
@@ -3096,6 +3096,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
|||||||
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
|
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
|
if (font_cfg_template == NULL || (font_cfg_template->Flags & ImFontFlags_NoLoadError) == 0)
|
||||||
IM_ASSERT_USER_ERROR(0, "Could not load font file!");
|
IM_ASSERT_USER_ERROR(0, "Could not load font file!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user