mirror of
https://github.com/ocornut/imgui.git
synced 2026-03-27 23:37:03 -05:00
Fonts: don't pretend to half recover from OOM for now + debug log filename on load failure.
This commit is contained in:
@@ -3102,7 +3102,10 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
|||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
if (font_cfg_template == NULL || (font_cfg_template->Flags & ImFontFlags_NoLoadError) == 0)
|
if (font_cfg_template == NULL || (font_cfg_template->Flags & ImFontFlags_NoLoadError) == 0)
|
||||||
|
{
|
||||||
|
IMGUI_DEBUG_LOG("While loading '%s'\n", filename);
|
||||||
IM_ASSERT_USER_ERROR(0, "Could not load font file!");
|
IM_ASSERT_USER_ERROR(0, "Could not load font file!");
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||||
@@ -4576,7 +4579,7 @@ static ImFontGlyph* ImGui_ImplStbTrueType_FontBakedLoadGlyph(ImFontAtlas* atlas,
|
|||||||
if (pack_id == ImFontAtlasRectId_Invalid)
|
if (pack_id == ImFontAtlasRectId_Invalid)
|
||||||
{
|
{
|
||||||
// Pathological out of memory case (TexMaxWidth/TexMaxHeight set too small?)
|
// Pathological out of memory case (TexMaxWidth/TexMaxHeight set too small?)
|
||||||
IM_ASSERT_USER_ERROR(pack_id != ImFontAtlasRectId_Invalid, "Out of texture memory.");
|
IM_ASSERT(pack_id != ImFontAtlasRectId_Invalid && "Out of texture memory.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ImTextureRect* r = ImFontAtlasPackGetRect(atlas, pack_id);
|
ImTextureRect* r = ImFontAtlasPackGetRect(atlas, pack_id);
|
||||||
|
|||||||
@@ -516,10 +516,10 @@ ImFontGlyph* ImGui_ImplFreeType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontCon
|
|||||||
if (is_visible)
|
if (is_visible)
|
||||||
{
|
{
|
||||||
ImFontAtlasRectId pack_id = ImFontAtlasPackAddRect(atlas, w, h);
|
ImFontAtlasRectId pack_id = ImFontAtlasPackAddRect(atlas, w, h);
|
||||||
if (pack_id < 0)
|
if (pack_id == ImFontAtlasRectId_Invalid)
|
||||||
{
|
{
|
||||||
// Pathological out of memory case (TexMaxWidth/TexMaxHeight set too small?)
|
// Pathological out of memory case (TexMaxWidth/TexMaxHeight set too small?)
|
||||||
IM_ASSERT_USER_ERROR(pack_id >= 0, "Out of texture memory.");
|
IM_ASSERT(pack_id != ImFontAtlasRectId_Invalid && "Out of texture memory.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ImTextureRect* r = ImFontAtlasPackGetRect(atlas, pack_id);
|
ImTextureRect* r = ImFontAtlasPackGetRect(atlas, pack_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user