Skip to content

Commit cfed18a

Browse files
committed
Add ImFontConfig::GlyphExtraAdvanceX as a replacement for GlyphExtraSpacing.x (ocornut#242)
Partly restore 1a31e31.
1 parent 2d20e13 commit cfed18a

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

docs/CHANGELOG.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ HOW TO UPDATE?
4141

4242
Breaking changes:
4343

44-
- Removed ImFontConfig::GlyphExtraSpacing option which seems largely obsolete and
45-
unused. If you were using this please report it! (#242).
44+
- Renamed ImFontConfig::GlyphExtraSpacing.x option to GlyphExtraAdvanceX. (#242)
4645

4746
Other changes:
4847

imgui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ CODE
430430
When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
431431
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
432432

433-
- 2025/02/03 (1.91.9) - removed ImFontConfig::GlyphExtraSpacing option which seems largely obsolete and unused. If you were using this please report it!
433+
- 2025/02/06 (1.91.9) - renamed ImFontConfig::GlyphExtraSpacing.x to ImFontConfig::GlyphExtraAdvanceX.
434434
- 2025/01/22 (1.91.8) - removed ImGuiColorEditFlags_AlphaPreview (made value 0): it is now the default behavior.
435435
prior to 1.91.8: alpha was made opaque in the preview by default _unless_ using ImGuiColorEditFlags_AlphaPreview. We now display the preview as transparent by default. You can use ImGuiColorEditFlags_AlphaOpaque to use old behavior.
436436
the new flags (ImGuiColorEditFlags_AlphaOpaque, ImGuiColorEditFlags_AlphaNoBg + existing ImGuiColorEditFlags_AlphaPreviewHalf) may be combined better and allow finer controls:

imgui.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// Library Version
3030
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
3131
#define IMGUI_VERSION "1.91.9 WIP"
32-
#define IMGUI_VERSION_NUM 19182
32+
#define IMGUI_VERSION_NUM 19183
3333
#define IMGUI_HAS_TABLE
3434

3535
/*
@@ -3257,11 +3257,12 @@ struct ImFontConfig
32573257
int OversampleH; // 0 (2) // Rasterize at higher quality for sub-pixel positioning. 0 == auto == 1 or 2 depending on size. Note the difference between 2 and 3 is minimal. You can reduce this to 1 for large glyphs save memory. Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.
32583258
int OversampleV; // 0 (1) // Rasterize at higher quality for sub-pixel positioning. 0 == auto == 1. This is not really useful as we don't use sub-pixel positions on the Y axis.
32593259
float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height).
3260-
//ImVec2 GlyphExtraSpacing; // 0, 0 // (REMOVED AT IT SEEMS LARGELY OBSOLETE. PLEASE REPORT IF YOU WERE USING THIS). Extra spacing (in pixels) between glyphs when rendered: essentially add to glyph->AdvanceX. Only X axis is supported for now.
3260+
//ImVec2 GlyphExtraSpacing; // 0, 0 // (REMOVED IN 1.91.9: use GlyphExtraAdvanceX)
32613261
ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input.
32623262
const ImWchar* GlyphRanges; // NULL // THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE. Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list).
32633263
float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font
32643264
float GlyphMaxAdvanceX; // FLT_MAX // Maximum AdvanceX for glyphs
3265+
float GlyphExtraAdvanceX; // 0 // Extra spacing (in pixels) between glyphs. Please contact us if you are using this.
32653266
unsigned int FontBuilderFlags; // 0 // Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure.
32663267
float RasterizerMultiply; // 1.0f // Linearly brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable. This is a silly thing we may remove in the future.
32673268
float RasterizerDensity; // 1.0f // DPI scale for rasterization, not altering other font metrics: make it easy to swap between e.g. a 100% and a 400% fonts for a zooming display. IMPORTANT: If you increase this it is expected that you increase font scale accordingly, otherwise quality may look lowered.

imgui_draw.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -3858,6 +3858,9 @@ void ImFont::AddGlyph(const ImFontConfig* cfg, ImWchar codepoint, float x0, floa
38583858
// Snap to pixel
38593859
if (cfg->PixelSnapH)
38603860
advance_x = IM_ROUND(advance_x);
3861+
3862+
// Bake extra spacing
3863+
advance_x += cfg->GlyphExtraAdvanceX;
38613864
}
38623865

38633866
int glyph_idx = Glyphs.Size;

0 commit comments

Comments
 (0)