1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-09 23:54:20 +00:00

Textures: Added atlas's TexMinWidth/TexMinHeight/TexMaxWidth/TexMaxHeight.

Fixed ImFontAtlasBuildGetTextureSizeEstimate().
Basic error handling on OOM.
This commit is contained in:
ocornut 2025-01-09 23:04:00 +01:00
parent 14614f561b
commit 2137b3448b
4 changed files with 43 additions and 9 deletions

View file

@ -509,6 +509,13 @@ bool ImGui_ImplFreeType_FontAddGlyph(ImFontAtlas* atlas, ImFont* font, ImFontCon
if (is_visible)
{
ImFontAtlasRectId pack_id = ImFontAtlasPackAddRect(atlas, w, h);
if (pack_id < 0)
{
// Pathological out of memory case (TexMaxWidth/TexMaxHeight set too small?)
IM_ASSERT_USER_ERROR(pack_id >= 0, "Out of texture memory.");
return false;
}
ImFontAtlasRect* r = ImFontAtlasPackGetRect(atlas, pack_id);
font->MetricsTotalSurface += w * h;