Fonts: Removed BuildClearGlyphs(), conflated with ClearOutputData()

This commit is contained in:
ocornut
2025-01-16 14:57:33 +01:00
parent 2bf6552f2f
commit bd19bc5085
2 changed files with 2 additions and 19 deletions

View File

@@ -3673,7 +3673,6 @@ struct ImFont
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last); IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
IMGUI_API ImFontGlyph* BuildLoadGlyph(ImWchar c); IMGUI_API ImFontGlyph* BuildLoadGlyph(ImWchar c);
IMGUI_API void BuildGrowIndex(int new_size); IMGUI_API void BuildGrowIndex(int new_size);
IMGUI_API void BuildClearGlyphs();
}; };
// Added indirection to avoid patching ImDrawCmd after texture updates. // Added indirection to avoid patching ImDrawCmd after texture updates.

View File

@@ -2522,8 +2522,6 @@ void ImTextureData::DestroyPixels()
// - ImFontAtlasPackGetRect() // - ImFontAtlasPackGetRect()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// - ImFont::BuildLoadGlyph() // - ImFont::BuildLoadGlyph()
// - ImFont::BuildClearGlyphs()
//-----------------------------------------------------------------------------
// - ImFontAtlasDebugLogTextureRequests() // - ImFontAtlasDebugLogTextureRequests()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// - ImFontAtlasGetFontLoaderForStbTruetype() // - ImFontAtlasGetFontLoaderForStbTruetype()
@@ -3581,7 +3579,7 @@ void ImFontAtlasBuildDiscardFontGlyphs(ImFontAtlas* atlas, ImFont* font)
for (ImFontGlyph& glyph : font->Glyphs) for (ImFontGlyph& glyph : font->Glyphs)
if (glyph.PackId >= 0) if (glyph.PackId >= 0)
ImFontAtlasPackDiscardRect(atlas, glyph.PackId); ImFontAtlasPackDiscardRect(atlas, glyph.PackId);
font->BuildClearGlyphs(); font->ClearOutputData();
font->FallbackChar = font->EllipsisChar = 0; font->FallbackChar = font->EllipsisChar = 0;
} }
@@ -3915,7 +3913,7 @@ void ImFontAtlasBuildInit(ImFontAtlas* atlas)
void ImFontAtlasBuildDestroy(ImFontAtlas* atlas) void ImFontAtlasBuildDestroy(ImFontAtlas* atlas)
{ {
for (ImFont* font : atlas->Fonts) for (ImFont* font : atlas->Fonts)
font->BuildClearGlyphs(); font->ClearOutputData();
if (atlas->FontLoader && atlas->FontLoader->FontSrcDestroy != NULL) if (atlas->FontLoader && atlas->FontLoader->FontSrcDestroy != NULL)
for (ImFontConfig& font_cfg : atlas->Sources) for (ImFontConfig& font_cfg : atlas->Sources)
atlas->FontLoader->FontSrcDestroy(atlas, &font_cfg); atlas->FontLoader->FontSrcDestroy(atlas, &font_cfg);
@@ -4650,30 +4648,16 @@ ImFont::~ImFont()
void ImFont::ClearOutputData() void ImFont::ClearOutputData()
{ {
FontSize = 0.0f;
FallbackAdvanceX = 0.0f; FallbackAdvanceX = 0.0f;
Glyphs.clear(); Glyphs.clear();
IndexAdvanceX.clear(); IndexAdvanceX.clear();
IndexLookup.clear(); IndexLookup.clear();
FallbackGlyphIndex = -1; FallbackGlyphIndex = -1;
ContainerAtlas = NULL;
Ascent = Descent = 0.0f; Ascent = Descent = 0.0f;
MetricsTotalSurface = 0; MetricsTotalSurface = 0;
memset(Used8kPagesMap, 0, sizeof(Used8kPagesMap)); memset(Used8kPagesMap, 0, sizeof(Used8kPagesMap));
} }
void ImFont::BuildClearGlyphs()
{
FallbackAdvanceX = 0.0f;
Glyphs.clear();
IndexAdvanceX.clear();
IndexLookup.clear();
FallbackGlyphIndex = 0;
MetricsTotalSurface = 0;
memset(Used8kPagesMap, 0, sizeof(Used8kPagesMap));
// Don't clear BuilderData
}
// API is designed this way to avoid exposing the 8K page size // API is designed this way to avoid exposing the 8K page size
// e.g. use with IsGlyphRangeUnused(0, 255) // e.g. use with IsGlyphRangeUnused(0, 255)
bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last) bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last)