From a856035678482874e6e9cabddd08257cd6c3c4ee Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 10 Feb 2025 22:53:33 +0100 Subject: [PATCH] WIP - Removed LockSingleSrcConfigIdx which isn't needed anymore since we don't load glyphs in ImFontAtlasBuildAddFont(). --- imgui.h | 1 - imgui_draw.cpp | 15 +++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/imgui.h b/imgui.h index 799aeadbb..884c6c2d6 100644 --- a/imgui.h +++ b/imgui.h @@ -3796,7 +3796,6 @@ struct ImFont float Scale; // 4 // in // Base font scale (~1.0f), multiplied by the per-window font scale which you can adjust with SetWindowFontScale() ImU8 Used8kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/8192/8]; // 1 bytes if ImWchar=ImWchar16, 16 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations across all used codepoints. bool EllipsisAutoBake; // 1 // // Mark when the "..." glyph needs to be generated. - short LockSingleSrcConfigIdx; // Methods IMGUI_API ImFont(); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 111336a2e..54c004870 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3640,14 +3640,11 @@ void ImFontAtlasBuildSetupFontSpecialGlyphs(ImFontAtlas* atlas, ImFont* font, Im IM_ASSERT(src_idx_in_font >= 0 && src_idx_in_font < font->SourcesCount); IM_UNUSED(atlas); - // While manipulating glyphs during init we want to restrict all searches for one source font. - font->LockSingleSrcConfigIdx = (short)src_idx_in_font; - // Find Fallback character. Actual glyph loaded in GetFontBaked(). const ImWchar fallback_chars[] = { font->FallbackChar, (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' }; if (font->FallbackChar == 0) for (ImWchar candidate_char : fallback_chars) - if (candidate_char != 0 && font->IsGlyphInFont(candidate_char)) // FIXME: does not respect LockSingleSrcConfigIdx() + if (candidate_char != 0 && font->IsGlyphInFont(candidate_char)) { font->FallbackChar = (ImWchar)candidate_char; break; @@ -3669,7 +3666,6 @@ void ImFontAtlasBuildSetupFontSpecialGlyphs(ImFontAtlas* atlas, ImFont* font, Im font->EllipsisChar = 0x0085; font->EllipsisAutoBake = true; } - font->LockSingleSrcConfigIdx = -1; } void ImFontAtlasBuildDiscardFontBakedGlyph(ImFontAtlas* atlas, ImFont* font, ImFontBaked* baked, ImFontGlyph* glyph) @@ -4293,15 +4289,11 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep if (ImFontGlyph* glyph = ImFontAtlasBuildSetupFontBakedEllipsis(atlas, baked)) return glyph; - // Load from single source or all sources? - int srcs_count = (font->LockSingleSrcConfigIdx != -1) ? 1 : font->SourcesCount; - ImFontConfig* srcs = (font->LockSingleSrcConfigIdx != -1) ? &font->Sources[font->LockSingleSrcConfigIdx] : font->Sources; - // Call backend char* loader_user_data_p = (char*)baked->FontLoaderDatas; - for (int src_n = 0; src_n < srcs_count; src_n++) + for (int src_n = 0; src_n < font->SourcesCount; src_n++) { - ImFontConfig* src = &srcs[src_n]; + ImFontConfig* src = &font->Sources[src_n]; const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader; if (!src->GlyphExcludeRanges || ImFontAtlasBuildAcceptCodepointForSource(src, codepoint)) if (ImFontGlyph* glyph = loader->FontBakedLoadGlyph(atlas, src, baked, loader_user_data_p, codepoint)) @@ -4887,7 +4879,6 @@ ImFont::ImFont() { memset(this, 0, sizeof(*this)); Scale = 1.0f; - LockSingleSrcConfigIdx = -1; } ImFont::~ImFont()