mirror of
https://github.com/ocornut/imgui.git
synced 2026-06-01 17:56:45 +08:00
Fonts: add ImFontGlyph::SourceIdx. Extract code out of DebugNodeFont() into DebugNodeFontGlyphesForSrcMask().
(src_mask unused in this commit)
This commit is contained in:
@@ -16700,6 +16700,17 @@ void ImGui::DebugNodeFont(ImFont* font)
|
|||||||
src_n, src->Name, src->OversampleH, oversample_h, src->OversampleV, oversample_v, src->PixelSnapH, src->GlyphOffset.x, src->GlyphOffset.y);
|
src_n, src->Name, src->OversampleH, oversample_h, src->OversampleV, oversample_v, src->PixelSnapH, src->GlyphOffset.x, src->GlyphOffset.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugNodeFontGlyphesForSrcMask(font, baked, ~0);
|
||||||
|
TreePop();
|
||||||
|
}
|
||||||
|
PopID();
|
||||||
|
}
|
||||||
|
TreePop();
|
||||||
|
Unindent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::DebugNodeFontGlyphesForSrcMask(ImFont* font, ImFontBaked* baked, int src_mask)
|
||||||
|
{
|
||||||
ImDrawList* draw_list = GetWindowDrawList();
|
ImDrawList* draw_list = GetWindowDrawList();
|
||||||
const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
|
const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
|
||||||
const float cell_size = baked->Size * 1;
|
const float cell_size = baked->Size * 1;
|
||||||
@@ -16717,7 +16728,8 @@ void ImGui::DebugNodeFont(ImFont* font)
|
|||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (unsigned int n = 0; n < 256; n++)
|
for (unsigned int n = 0; n < 256; n++)
|
||||||
if (baked->IsGlyphLoaded((ImWchar)(base + n)))
|
if (const ImFontGlyph* glyph = baked->IsGlyphLoaded((ImWchar)(base + n)) ? baked->FindGlyph((ImWchar)(base + n)) : NULL)
|
||||||
|
if (src_mask & (1 << glyph->SourceIdx))
|
||||||
count++;
|
count++;
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
continue;
|
continue;
|
||||||
@@ -16734,7 +16746,7 @@ void ImGui::DebugNodeFont(ImFont* font)
|
|||||||
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
|
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
|
||||||
const ImFontGlyph* glyph = baked->IsGlyphLoaded((ImWchar)(base + n)) ? baked->FindGlyph((ImWchar)(base + n)) : NULL;
|
const ImFontGlyph* glyph = baked->IsGlyphLoaded((ImWchar)(base + n)) ? baked->FindGlyph((ImWchar)(base + n)) : NULL;
|
||||||
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
|
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
|
||||||
if (!glyph)
|
if (!glyph || (src_mask & (1 << glyph->SourceIdx)) == 0)
|
||||||
continue;
|
continue;
|
||||||
font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
|
font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
|
||||||
if (IsMouseHoveringRect(cell_p1, cell_p2) && BeginTooltip())
|
if (IsMouseHoveringRect(cell_p1, cell_p2) && BeginTooltip())
|
||||||
@@ -16746,12 +16758,6 @@ void ImGui::DebugNodeFont(ImFont* font)
|
|||||||
Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
|
Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
TreePop();
|
|
||||||
}
|
|
||||||
PopID();
|
|
||||||
}
|
|
||||||
TreePop();
|
|
||||||
Unindent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph)
|
void ImGui::DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph)
|
||||||
@@ -16767,6 +16773,7 @@ void ImGui::DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph)
|
|||||||
ImTextureRect* r = ImFontAtlasPackGetRect(font->ContainerAtlas, glyph->PackId);
|
ImTextureRect* r = ImFontAtlasPackGetRect(font->ContainerAtlas, glyph->PackId);
|
||||||
Text("PackId: %d (%dx%d rect at %d,%d)", glyph->PackId, r->w, r->h, r->x, r->y);
|
Text("PackId: %d (%dx%d rect at %d,%d)", glyph->PackId, r->w, r->h, r->x, r->y);
|
||||||
}
|
}
|
||||||
|
Text("SourceIdx: %d", glyph->SourceIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [DEBUG] Display contents of ImGuiStorage
|
// [DEBUG] Display contents of ImGuiStorage
|
||||||
@@ -17429,6 +17436,7 @@ void ImGui::DebugNodeColumns(ImGuiOldColumns*) {}
|
|||||||
void ImGui::DebugNodeDrawList(ImGuiWindow*, ImGuiViewportP*, const ImDrawList*, const char*) {}
|
void ImGui::DebugNodeDrawList(ImGuiWindow*, ImGuiViewportP*, const ImDrawList*, const char*) {}
|
||||||
void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList*, const ImDrawList*, const ImDrawCmd*, bool, bool) {}
|
void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList*, const ImDrawList*, const ImDrawCmd*, bool, bool) {}
|
||||||
void ImGui::DebugNodeFont(ImFont*) {}
|
void ImGui::DebugNodeFont(ImFont*) {}
|
||||||
|
void ImGui::DebugNodeFontGlyphesForSrcMask(ImFont*, ImFontBaked*, int) {}
|
||||||
void ImGui::DebugNodeStorage(ImGuiStorage*, const char*) {}
|
void ImGui::DebugNodeStorage(ImGuiStorage*, const char*) {}
|
||||||
void ImGui::DebugNodeTabBar(ImGuiTabBar*, const char*) {}
|
void ImGui::DebugNodeTabBar(ImGuiTabBar*, const char*) {}
|
||||||
void ImGui::DebugNodeWindow(ImGuiWindow*, const char*) {}
|
void ImGui::DebugNodeWindow(ImGuiWindow*, const char*) {}
|
||||||
|
|||||||
@@ -3484,7 +3484,8 @@ struct ImFontGlyph
|
|||||||
{
|
{
|
||||||
unsigned int Colored : 1; // Flag to indicate glyph is colored and should generally ignore tinting (make it usable with no shift on little-endian as this is used in loops)
|
unsigned int Colored : 1; // Flag to indicate glyph is colored and should generally ignore tinting (make it usable with no shift on little-endian as this is used in loops)
|
||||||
unsigned int Visible : 1; // Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering.
|
unsigned int Visible : 1; // Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering.
|
||||||
unsigned int Codepoint : 30; // 0x0000..0x10FFFF
|
unsigned int SourceIdx : 4; // Index of source in parent font
|
||||||
|
unsigned int Codepoint : 26; // 0x0000..0x10FFFF
|
||||||
float AdvanceX; // Horizontal distance to advance cursor/layout position.
|
float AdvanceX; // Horizontal distance to advance cursor/layout position.
|
||||||
float X0, Y0, X1, Y1; // Glyph corners. Offsets from current cursor/layout position.
|
float X0, Y0, X1, Y1; // Glyph corners. Offsets from current cursor/layout position.
|
||||||
float U0, V0, U1, V1; // Texture coordinates for the current value of ImFontAtlas->TexRef. Cached equivalent of calling GetCustomRect() with PackId.
|
float U0, V0, U1, V1; // Texture coordinates for the current value of ImFontAtlas->TexRef. Cached equivalent of calling GetCustomRect() with PackId.
|
||||||
|
|||||||
+5
-1
@@ -4390,7 +4390,11 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep
|
|||||||
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
|
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
|
||||||
if (!src->GlyphExcludeRanges || ImFontAtlasBuildAcceptCodepointForSource(src, codepoint))
|
if (!src->GlyphExcludeRanges || ImFontAtlasBuildAcceptCodepointForSource(src, codepoint))
|
||||||
if (ImFontGlyph* glyph = loader->FontBakedLoadGlyph(atlas, src, baked, loader_user_data_p, codepoint))
|
if (ImFontGlyph* glyph = loader->FontBakedLoadGlyph(atlas, src, baked, loader_user_data_p, codepoint))
|
||||||
return glyph; // FIXME: Add hooks for e.g. #7962
|
{
|
||||||
|
// FIXME: Add hooks for e.g. #7962
|
||||||
|
glyph->SourceIdx = src_n;
|
||||||
|
return glyph;
|
||||||
|
}
|
||||||
loader_user_data_p += loader->FontBakedSrcLoaderDataSize;
|
loader_user_data_p += loader->FontBakedSrcLoaderDataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3625,6 +3625,7 @@ namespace ImGui
|
|||||||
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label);
|
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label);
|
||||||
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
|
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
|
||||||
IMGUI_API void DebugNodeFont(ImFont* font);
|
IMGUI_API void DebugNodeFont(ImFont* font);
|
||||||
|
IMGUI_API void DebugNodeFontGlyphesForSrcMask(ImFont* font, ImFontBaked* baked, int src_mask);
|
||||||
IMGUI_API void DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph);
|
IMGUI_API void DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph);
|
||||||
IMGUI_API void DebugNodeTexture(ImTextureData* tex, int int_id, const ImFontAtlasRect* highlight_rect = NULL); // ID used to facilitate persisting the "current" texture.
|
IMGUI_API void DebugNodeTexture(ImTextureData* tex, int int_id, const ImFontAtlasRect* highlight_rect = NULL); // ID used to facilitate persisting the "current" texture.
|
||||||
IMGUI_API void DebugNodeStorage(ImGuiStorage* storage, const char* label);
|
IMGUI_API void DebugNodeStorage(ImGuiStorage* storage, const char* label);
|
||||||
|
|||||||
Reference in New Issue
Block a user