MCPcopy Create free account
hub / github.com/cinder/Cinder / ImFontAtlasPackGetRectSafe

Function ImFontAtlasPackGetRectSafe

src/imgui/imgui_draw.cpp:4370–4385  ·  view source on GitHub ↗

For user-facing functions: return NULL on invalid ID. Important: return pointer is valid until next call to AddRect(), e.g. FindGlyph(), CalcTextSize() can all potentially invalidate previous pointers.

Source from the content-addressed store, hash-verified

4368// For user-facing functions: return NULL on invalid ID.
4369// Important: return pointer is valid until next call to AddRect(), e.g. FindGlyph(), CalcTextSize() can all potentially invalidate previous pointers.
4370ImTextureRect* ImFontAtlasPackGetRectSafe(ImFontAtlas* atlas, ImFontAtlasRectId id)
4371{
4372 if (id == ImFontAtlasRectId_Invalid)
4373 return NULL;
4374 int index_idx = ImFontAtlasRectId_GetIndex(id);
4375 if (atlas->Builder == NULL)
4376 ImFontAtlasBuildInit(atlas);
4377 ImFontAtlasBuilder* builder = (ImFontAtlasBuilder*)atlas->Builder;
4378 IM_MSVC_WARNING_SUPPRESS(28182); // Static Analysis false positive "warning C28182: Dereferencing NULL pointer 'builder'"
4379 if (index_idx >= builder->RectsIndex.Size)
4380 return NULL;
4381 ImFontAtlasRectEntry* index_entry = &builder->RectsIndex[index_idx];
4382 if (index_entry->Generation != ImFontAtlasRectId_GetGeneration(id) || !index_entry->IsUsed)
4383 return NULL;
4384 return &builder->Rects[index_entry->TargetIndex];
4385}
4386
4387// Important! This assume by ImFontConfig::GlyphExcludeRanges[] is a SMALL ARRAY (e.g. <10 entries)
4388// Use "Input Glyphs Overlap Detection Tool" to display a list of glyphs provided by multiple sources in order to set this array up.

Callers 2

RemoveCustomRectMethod · 0.85
GetCustomRectMethod · 0.85

Calls 3

ImFontAtlasBuildInitFunction · 0.85

Tested by

no test coverage detected