ImFontAtlas: move implicit AddFontDefault call to Build() function + remove unnecessary asserts in backend.

This commit is contained in:
ocornut
2021-06-24 17:34:23 +02:00
parent 2ab7f96f21
commit 95db098477
7 changed files with 7 additions and 12 deletions

View File

@ -2033,11 +2033,7 @@ void ImFontAtlas::GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_wid
{
// Build atlas on demand
if (TexPixelsAlpha8 == NULL)
{
if (ConfigData.empty())
AddFontDefault();
Build();
}
*out_pixels = TexPixelsAlpha8;
if (out_width) *out_width = TexWidth;
@ -2258,6 +2254,10 @@ bool ImFontAtlas::Build()
{
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
// Default font is none are specified
if (ConfigData.Size == 0)
AddFontDefault();
// Select builder
// - Note that we do not reassign to atlas->FontBuilderIO, since it is likely to point to static data which
// may mess with some hot-reloading schemes. If you need to assign to this (for dynamic selection) AND are