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.
| 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. |
| 4370 | ImTextureRect* 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. |
no test coverage detected