Skip to content

Centre toolbar glyphs by their drawn pixels, add GlyphSize, and fix the gallery tile's icons - #576

Merged
matt-edmondson merged 3 commits into
mainfrom
claude/project-thread-5le24s
Sep 30, 2026
Merged

matt-edmondson merged 3 commits into
mainfrom
claude/project-thread-5le24s

Conversation

@matt-edmondson

@matt-edmondson matt-edmondson commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Before: in the Toolbar gallery tile, icons sat high in their buttons. A leading icon sat above the label's midline, and an icon placed above its label left a gap under it. The Bold toggle drew a radioactive symbol instead of a bold "B". Icons could only be drawn at the label's font size.

After: the drawn pixels of each icon are centred in a slot one glyph size tall, which is the same for every glyph. Icons line up with their labels, labels in a glyph-above row stay level, and the tile draws the intended icons. A new GlyphSize option (in pixels) on ToolbarOptions and ToolbarButtonOptions draws icons larger or smaller than their labels, from the same font.

An icon font merged into a text font keeps its own vertical metrics, so centring the line box leaves the icon off-centre. ToolbarButton now reads the ink bounds of the glyph from the baked font. The pure correction is ToolbarGeometry.GlyphInkCorrection, which is unit-tested. Horizontal ink centring only applies where the glyph is centred (GlyphOnly and GlyphAbove). A leading glyph keeps its advance, so the gap between glyph and label stays the style's.

GlyphSize resolves in this order: the button's own value, then the toolbar's value, then the current font size. The glyph is measured and drawn with ImGui.PushFont(ImGui.GetFont(), size), so it needs no extra font registration. A toolbar's GlyphSize grows its row through a new ToolbarGeometry.RowHeight overload that takes a separate glyph line height. The existing overload is kept and delegates to it. A button whose own glyph is larger than its toolbar's is taller than the row, and the doc comment says to set the size on the toolbar instead.

Gallery icons: U+E238 (format_bold) falls inside the Nerd Font's Font Awesome Extension range (E200–E2A9), and U+E8B8 (settings) falls inside its Devicons range (E700–E8EF). The merge keeps the first font's glyph, so the Nerd Font's icon won both times. The tile now uses Preview (U+E8F4) and Tune (U+E429), which no Nerd Font range claims. Its two-line toolbar also shows GlyphSize = 24.

How: I rendered the tile locally with the pinned Material Icons font (--only Toolbar) and compared it against main's image. The gallery bot regenerates docs/gallery after merge. These pass after merging current main: ImGui.Widgets.Tests (982, including two new RowHeight cases), the Toolbar isolation tests (21, including four new GlyphSize tests), WidgetGallery.UITests, and the demo's Toolbar test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Drads1iNzcCuWc8iJ6iGMw

…'s Bold icon

An icon font merged into the text font keeps its own vertical metrics, so glyphs drew
high in their line box: above the label's midline in a leading button, and with a gap
under them in a glyph-above button. Buttons now centre a glyph's drawn pixels in a slot
one font size tall, so every glyph in a row sits level and labels stay aligned.

The gallery tile's Bold toggle used U+E238, which falls inside the Nerd Font's Font
Awesome Extension block and drew that font's glyph instead of Material's format_bold.
It is now a Preview toggle on U+E8F4, which no Nerd Font range claims.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Drads1iNzcCuWc8iJ6iGMw
A toolbar or a single button can now draw its glyph at its own pixel size,
from the same font, so icons can be larger than the labels beside them. The
toolbar's row grows to fit its glyph size; labels stay at the font size.

The gallery tile shows a 24px two-line toolbar, and swaps U+E8B8 (settings),
which the Nerd Font's Devicons block claims, for Material's tune at U+E429.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Drads1iNzcCuWc8iJ6iGMw
@matt-edmondson matt-edmondson changed the title Centre toolbar glyphs by their drawn pixels, and fix the gallery tile's Bold icon Centre toolbar glyphs by their drawn pixels, add GlyphSize, and fix the gallery tile's icons Sep 30, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants