MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / ImFontAtlasBuildFinish

Function ImFontAtlasBuildFinish

lib/imgui/imgui_draw.cpp:2280–2319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2278}
2279
2280void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
2281{
2282 // Render into our custom data block
2283 ImFontAtlasBuildRenderDefaultTexData(atlas);
2284
2285 // Register custom rectangle glyphs
2286 for (int i = 0; i < atlas->CustomRects.Size; i++)
2287 {
2288 const ImFontAtlasCustomRect& r = atlas->CustomRects[i];
2289 if (r.Font == NULL || r.ID >= 0x110000)
2290 continue;
2291
2292 IM_ASSERT(r.Font->ContainerAtlas == atlas);
2293 ImVec2 uv0, uv1;
2294 atlas->CalcCustomRectUV(&r, &uv0, &uv1);
2295 r.Font->AddGlyph((ImWchar)r.ID, r.GlyphOffset.x, r.GlyphOffset.y, r.GlyphOffset.x + r.Width, r.GlyphOffset.y + r.Height, uv0.x, uv0.y, uv1.x, uv1.y, r.GlyphAdvanceX);
2296 }
2297
2298 // Build all fonts lookup tables
2299 for (int i = 0; i < atlas->Fonts.Size; i++)
2300 if (atlas->Fonts[i]->DirtyLookupTables)
2301 atlas->Fonts[i]->BuildLookupTable();
2302
2303 // Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
2304 // However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
2305 // FIXME: Also note that 0x2026 is currently seldomly included in our font ranges. Because of this we are more likely to use three individual dots.
2306 for (int i = 0; i < atlas->Fonts.size(); i++)
2307 {
2308 ImFont* font = atlas->Fonts[i];
2309 if (font->EllipsisChar != (ImWchar)-1)
2310 continue;
2311 const ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
2312 for (int j = 0; j < IM_ARRAYSIZE(ellipsis_variants); j++)
2313 if (font->FindGlyphNoFallback(ellipsis_variants[j]) != NULL) // Verify glyph exists
2314 {
2315 font->EllipsisChar = ellipsis_variants[j];
2316 break;
2317 }
2318 }
2319}
2320
2321// Retrieve list of range (2 int per range, values are inclusive)
2322const ImWchar* ImFontAtlas::GetGlyphRangesDefault()

Callers 2

Calls 6

CalcCustomRectUVMethod · 0.80
AddGlyphMethod · 0.80
BuildLookupTableMethod · 0.80
FindGlyphNoFallbackMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected