Skip to content

Commit 9da53bc

Browse files
committed
ImFontConfig: Removed MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset. (Breaking change)
1 parent 026d021 commit 9da53bc

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

imgui.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@
152152
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
153153
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
154154
155-
- 2017/05/01 (1.50) - Renamed ImDrawList::PathFill() to ImDrawList::PathFillConvex() for clarity.
155+
- 2017/05/26 (1.50) - Removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset.
156+
- 2017/05/01 (1.50) - Renamed ImDrawList::PathFill() (rarely used directly) to ImDrawList::PathFillConvex() for clarity.
156157
- 2016/11/06 (1.50) - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild().
157158
- 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it.
158159
- 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.

imgui.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,8 +1272,7 @@ struct ImFontConfig
12721272
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs
12731273
ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input
12741274
const ImWchar* GlyphRanges; // // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
1275-
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
1276-
bool MergeGlyphCenterV; // false // When merging (multiple ImFontInput for one ImFont), vertically center new glyphs instead of aligning their baseline. Prefer using an explicit GlyphOffset.y setting instead, may obsolete MergeGlyphCenterV.
1275+
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights.
12771276

12781277
// [Internal]
12791278
char Name[32]; // Name (strictly for debugging)

imgui_draw.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,6 @@ ImFontConfig::ImFontConfig()
10461046
GlyphOffset = ImVec2(0.0f, 0.0f);
10471047
GlyphRanges = NULL;
10481048
MergeMode = false;
1049-
MergeGlyphCenterV = false;
10501049
DstFont = NULL;
10511050
memset(Name, 0, sizeof(Name));
10521051
}
@@ -1427,8 +1426,8 @@ bool ImFontAtlas::Build()
14271426
dst_font->MetricsTotalSurface = 0;
14281427
}
14291428
dst_font->ConfigDataCount++;
1430-
float off_x = cfg.GlyphOffset.x, off_y = cfg.GlyphOffset.y;
1431-
float merge_off_y = (cfg.MergeMode && cfg.MergeGlyphCenterV) ? (ascent - dst_font->Ascent) * 0.5f : 0.0f;
1429+
float off_x = cfg.GlyphOffset.x;
1430+
float off_y = cfg.GlyphOffset.y;
14321431

14331432
dst_font->FallbackGlyph = NULL; // Always clear fallback so FindGlyph can return NULL. It will be set again in BuildLookupTable()
14341433
for (int i = 0; i < tmp.RangesCount; i++)
@@ -1453,8 +1452,8 @@ bool ImFontAtlas::Build()
14531452
glyph.Codepoint = (ImWchar)codepoint;
14541453
glyph.X0 = q.x0 + off_x; glyph.Y0 = q.y0 + off_y; glyph.X1 = q.x1 + off_x; glyph.Y1 = q.y1 + off_y;
14551454
glyph.U0 = q.s0; glyph.V0 = q.t0; glyph.U1 = q.s1; glyph.V1 = q.t1;
1456-
glyph.Y0 += (float)(int)(dst_font->Ascent + merge_off_y + 0.5f);
1457-
glyph.Y1 += (float)(int)(dst_font->Ascent + merge_off_y + 0.5f);
1455+
glyph.Y0 += (float)(int)(dst_font->Ascent + 0.5f);
1456+
glyph.Y1 += (float)(int)(dst_font->Ascent + 0.5f);
14581457
glyph.XAdvance = (pc.xadvance + cfg.GlyphExtraSpacing.x); // Bake spacing into XAdvance
14591458
if (cfg.PixelSnapH)
14601459
glyph.XAdvance = (float)(int)(glyph.XAdvance + 0.5f);

0 commit comments

Comments
 (0)