Skip to content

Commit 1a31e31

Browse files
committed
(Breaking) Fonts: removed ImFontConfig::GlyphExtraSpacing option which seems largely obsolete and unused. (ocornut#242)
1 parent de962e8 commit 1a31e31

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

docs/CHANGELOG.txt

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ 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).
46+
4447
Other changes:
4548

4649
- Fixed IsItemDeactivatedAfterEdit() signal being broken for Checkbox(),

docs/FONTS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ ImGui::PopFont();
110110
**For advanced options create a ImFontConfig structure and pass it to the AddFont() function (it will be copied internally):**
111111
```cpp
112112
ImFontConfig config;
113-
config.GlyphExtraSpacing.x = 1.0f;
113+
config.RasterizerDensity = 2.0f;
114114
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
115115
```
116116

imgui.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -430,6 +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!
433434
- 2025/01/22 (1.91.8) - removed ImGuiColorEditFlags_AlphaPreview (made value 0): it is now the default behavior.
434435
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.
435436
the new flags (ImGuiColorEditFlags_AlphaOpaque, ImGuiColorEditFlags_AlphaNoBg + existing ImGuiColorEditFlags_AlphaPreviewHalf) may be combined better and allow finer controls:

imgui.h

+3-3
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 19181
32+
#define IMGUI_VERSION_NUM 19182
3333
#define IMGUI_HAS_TABLE
3434

3535
/*
@@ -3257,7 +3257,7 @@ 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 // 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 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.
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
@@ -3281,7 +3281,7 @@ struct ImFontGlyph
32813281
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)
32823282
unsigned int Visible : 1; // Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering.
32833283
unsigned int Codepoint : 30; // 0x0000..0x10FFFF
3284-
float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
3284+
float AdvanceX; // Horizontal distance to advance layout with
32853285
float X0, Y0, X1, Y1; // Glyph corners
32863286
float U0, V0, U1, V1; // Texture coordinates
32873287
};

imgui_draw.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -3349,7 +3349,7 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
33493349
if (r->Font == NULL || r->GlyphID == 0)
33503350
continue;
33513351

3352-
// Will ignore ImFontConfig settings: GlyphMinAdvanceX, GlyphMinAdvanceY, GlyphExtraSpacing, PixelSnapH
3352+
// Will ignore ImFontConfig settings: GlyphMinAdvanceX, GlyphMinAdvanceY, PixelSnapH
33533353
IM_ASSERT(r->Font->ContainerAtlas == atlas);
33543354
ImVec2 uv0, uv1;
33553355
atlas->CalcCustomRectUV(r, &uv0, &uv1);
@@ -3858,9 +3858,6 @@ 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 spacing
3863-
advance_x += cfg->GlyphExtraSpacing.x;
38643861
}
38653862

38663863
int glyph_idx = Glyphs.Size;

0 commit comments

Comments
 (0)