Skip to content

Commit 4c0604e

Browse files
committed
Font: shallow refactor, rename ConfigData[] fields to Sources[], ConfigDataCount to SourcesCount.
In theory this is all internal stuff.
1 parent 6e29450 commit 4c0604e

File tree

5 files changed

+98
-98
lines changed

5 files changed

+98
-98
lines changed

imgui.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -16215,7 +16215,7 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
1621516215
void ImGui::DebugNodeFont(ImFont* font)
1621616216
{
1621716217
bool opened = TreeNode(font, "Font: \"%s\": %.2f px, %d glyphs, %d sources(s)",
16218-
font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
16218+
font->Sources ? font->Sources[0].Name : "", font->FontSize, font->Glyphs.Size, font->SourcesCount);
1621916219

1622016220
// Display preview text
1622116221
if (!opened)
@@ -16248,14 +16248,14 @@ void ImGui::DebugNodeFont(ImFont* font)
1624816248
Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar);
1624916249
const int surface_sqrt = (int)ImSqrt((float)font->MetricsTotalSurface);
1625016250
Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
16251-
for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
16252-
if (font->ConfigData)
16251+
for (int config_i = 0; config_i < font->SourcesCount; config_i++)
16252+
if (font->Sources)
1625316253
{
16254-
const ImFontConfig* cfg = &font->ConfigData[config_i];
16254+
const ImFontConfig* src = &font->Sources[config_i];
1625516255
int oversample_h, oversample_v;
16256-
ImFontAtlasBuildGetOversampleFactors(cfg, &oversample_h, &oversample_v);
16256+
ImFontAtlasBuildGetOversampleFactors(src, &oversample_h, &oversample_v);
1625716257
BulletText("Input %d: \'%s\', Oversample: (%d=>%d,%d=>%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
16258-
config_i, cfg->Name, cfg->OversampleH, oversample_h, cfg->OversampleV, oversample_v, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
16258+
config_i, src->Name, src->OversampleH, oversample_h, src->OversampleV, oversample_v, src->PixelSnapH, src->GlyphOffset.x, src->GlyphOffset.y);
1625916259
}
1626016260

1626116261
// Display all glyphs of the fonts in separate pages of 256 characters

imgui.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -3441,7 +3441,7 @@ struct ImFontAtlas
34413441
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
34423442
ImVector<ImFont*> Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
34433443
ImVector<ImFontAtlasCustomRect> CustomRects; // Rectangles for packing custom texture data into the atlas.
3444-
ImVector<ImFontConfig> ConfigData; // Configuration data
3444+
ImVector<ImFontConfig> Sources; // Source/configuration data
34453445
ImVec4 TexUvLines[IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1]; // UVs for baked anti-aliased lines
34463446

34473447
// [Internal] Font builder
@@ -3472,10 +3472,10 @@ struct ImFont
34723472
ImFontGlyph* FallbackGlyph; // 4-8 // out // = FindGlyph(FontFallbackChar)
34733473

34743474
// [Internal] Members: Cold ~32/40 bytes
3475-
// Conceptually ConfigData[] is the list of font sources merged to create this font.
3475+
// Conceptually Sources[] is the list of font sources merged to create this font.
34763476
ImFontAtlas* ContainerAtlas; // 4-8 // out // What we has been loaded into
3477-
const ImFontConfig* ConfigData; // 4-8 // in // Pointer within ContainerAtlas->ConfigData to ConfigDataCount instances
3478-
short ConfigDataCount; // 2 // in // Number of ImFontConfig involved in creating this font. Usually 1, or >1 when merging multiple font sources into one ImFont.
3477+
ImFontConfig* Sources; // 4-8 // in // Pointer within ContainerAtlas->Sources[], to SourcesCount instances
3478+
short SourcesCount; // 2 // in // Number of ImFontConfig involved in creating this font. Usually 1, or >1 when merging multiple font sources into one ImFont.
34793479
short EllipsisCharCount; // 1 // out // 1 or 3
34803480
ImWchar EllipsisChar; // 2-4 // out // Character used for ellipsis rendering ('...').
34813481
ImWchar FallbackChar; // 2-4 // out // Character used if a glyph isn't found (U+FFFD, '?')
@@ -3494,7 +3494,7 @@ struct ImFont
34943494
IMGUI_API ImFontGlyph* FindGlyphNoFallback(ImWchar c);
34953495
float GetCharAdvance(ImWchar c) { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
34963496
bool IsLoaded() const { return ContainerAtlas != NULL; }
3497-
const char* GetDebugName() const { return ConfigData ? ConfigData->Name : "<unknown>"; }
3497+
const char* GetDebugName() const { return Sources ? Sources->Name : "<unknown>"; }
34983498

34993499
// [Internal] Don't use!
35003500
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.

0 commit comments

Comments
 (0)