[PR #3416] [MERGED] Name tags: draw text as Font.prepareText does (bold, tall glyphs) #4966

Closed
opened 2026-11-03 05:09:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3416
Author: @d3grando
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3084-cyrillic-bold


📝 Commits (1)

  • 0352ad0 Name tags: draw text as Font.prepareText does (bold, tall glyphs)

📊 Changes

2 files changed (+122 additions, -66 deletions)

View changed files

📝 crates/horizon-client-render/src/hud.rs (+86 -0)
📝 crates/horizon-client/src/game/names.rs (+36 -66)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Fixes #3084.

Name tags (custom names over mobs and armor-stand holograms, player names, item frame names) had their own glyph loop in game/names.rs that ignored the text's style and the glyphs' boxes:

  • every glyph was drawn as an 8x8 quad at the line top, so accented.png glyphs (9x12 cells, height 12, ascent 10) were squeezed into 8x8. That's why "й" looked wrong in the report: its breve sat inside the cap height instead of above it. Other accented.png letters (Ё, Й, À, É…) and Unifont glyphs were distorted the same way;
  • bold, italic, underline, strikethrough, obfuscated and the font style were never applied, so a server's bold hologram ("BUILDBATTLE") came out thin;
  • the width ignored bold advances, the line was centred at -trunc(width / 2) instead of vanilla's -Font.width / 2f, and the background stopped 8 pixels below the line top instead of 9.

Vanilla draws name tags like any other text (Font.prepareText), so the name tag now does too: the new HudBatch::name_tag (hud.rs) lays the line out with text_styled, the same styled glyph path the HUD and text displays use, and puts the background behind it. names.rs then maps those quads into the world as before (same corner order, the same 0.002 offset for the background, the same layers and light). Glyphs rasterized on first use (Unifont's) now go into map_patches, like text displays' do.

Text displays already went through text_styled and are unchanged. The chat was already correct.

Vanilla reference

  • SubmitNodeCollection.submitNameTag: x = -Font.width(component) / 2f (ineg i2f fconst_2 fdiv), y = 0, the NORMAL pass without a background, then the SEE_THROUGH pass (or the discrete one) with ARGB.color(getBackgroundOpacity(0.25), black), both via nameTag(...) → TextFeatureRenderer.Content.Text(x, y, seq, dropShadow=false, color, background, 0).
  • TextFeatureRenderer.renderText → Font.prepareText(seq, x, y, color, dropShadow, …, backgroundColor) → Font.PreparedTextBuilder.accept: styled BakedGlyphs (bold copy at getBoldOffset, advance getAdvance(bold)), strikethrough and underline effects, and markBackground(x, y, advance): left x - 1, top y - 1, right x + advance, bottom y + 9.
  • Font.width(FormattedText) = Mth.ceil(StringSplitter.stringWidth(text)).
  • Assets: font/include/default.json puts й/Й (U+0439/U+0419) only in accented.png (row 13, columns 5/4; height 12, ascent 10, 144x900 sheet → 9x12 cells), not in nonlatin_european.png.

Read from the pinned 26.3 client jar with javap -c -p. No harness covers name tag geometry; the new unit test hud::tests::name_tags_draw_bold_text_and_tall_glyphs_like_any_text checks the layout. It fails on main's algorithm ([-6.0, 0.0, 2.0, 8.0] != [-7.6, -0.1, 0.6, 8.1]: an 8x8 cell, no bold) and passes with the fix.

Self-check

Run on Windows (tools/pr_ready.py and tools/parity.py don't run on Windows: signal.SIGHUP), so these were run by hand:

cargo fmt --all -- --check                                                    ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings   ok
cargo test -p horizon-client --features mods --lib --bins --tests --no-fail-fast
    lib 1109 passed, 1 failed (save::tests::session_lock_is_exclusive: Windows-only, save.rs untouched)
    bin 139, horizon-ctl 18, integration 10: all passed
cargo test -p horizon-client --lib name_tags_draw                             ok (fails on main's algorithm)

Screenshots

Armor-stand holograms in a creative world (--in-frame), lang:ru_ru: {text:'BUILDBATTLE',color:'yellow',bold:true}, Онлайн режима: 173, Нажмите, чтобы играть, and bold red Важно для вашей безопасности!!!.

Before (main; same output on macOS with 0.2.97, where the report came from): BUILDBATTLE and the red line aren't bold, and "й" is squeezed into the line height.

Before

After: bold lines are bold, "й" has its breve above the line as in vanilla, and the background is one pixel taller (vanilla's y + 9).

After

Note: holograms summoned in the default server-thread single player didn't show their names at all on main (the client's armor stands had neither the custom name nor Invisible/Marker), so these shots use --in-frame. That's a separate sync gap and isn't touched here. Holograms from a real server, as in the report, do show.

Rebased on main after #3186

Rebased on main after #3186, re-checked on Windows 11: cargo fmt --all -- --check ok; cargo clippy -p horizon-client-render --all-targets -- -D warnings and cargo clippy -p horizon-client --features mods --all-targets -- -D warnings ok; cargo test -p horizon-client-render --lib hud:: 16 passed (including name_tags_draw_bold_text_and_tall_glyphs_like_any_text).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3416 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3084-cyrillic-bold` --- ### 📝 Commits (1) - [`0352ad0`](https://github.com/horizon-rust/horizon/commit/0352ad0e19188e39f700ed6193222f3e7dd8ae47) Name tags: draw text as Font.prepareText does (bold, tall glyphs) ### 📊 Changes **2 files changed** (+122 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/hud.rs` (+86 -0) 📝 `crates/horizon-client/src/game/names.rs` (+36 -66) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3084. Name tags (custom names over mobs and armor-stand holograms, player names, item frame names) had their own glyph loop in `game/names.rs` that ignored the text's style and the glyphs' boxes: - every glyph was drawn as an 8x8 quad at the line top, so `accented.png` glyphs (9x12 cells, height 12, ascent 10) were squeezed into 8x8. That's why "й" looked wrong in the report: its breve sat inside the cap height instead of above it. Other `accented.png` letters (Ё, Й, À, É…) and Unifont glyphs were distorted the same way; - bold, italic, underline, strikethrough, obfuscated and the `font` style were never applied, so a server's bold hologram ("BUILDBATTLE") came out thin; - the width ignored bold advances, the line was centred at `-trunc(width / 2)` instead of vanilla's `-Font.width / 2f`, and the background stopped 8 pixels below the line top instead of 9. Vanilla draws name tags like any other text (`Font.prepareText`), so the name tag now does too: the new `HudBatch::name_tag` (hud.rs) lays the line out with `text_styled`, the same styled glyph path the HUD and text displays use, and puts the background behind it. `names.rs` then maps those quads into the world as before (same corner order, the same 0.002 offset for the background, the same layers and light). Glyphs rasterized on first use (Unifont's) now go into `map_patches`, like text displays' do. Text displays already went through `text_styled` and are unchanged. The chat was already correct. ## Vanilla reference - `SubmitNodeCollection.submitNameTag`: `x = -Font.width(component) / 2f` (`ineg i2f fconst_2 fdiv`), y = 0, the `NORMAL` pass without a background, then the `SEE_THROUGH` pass (or the discrete one) with `ARGB.color(getBackgroundOpacity(0.25), black)`, both via `nameTag(...)` → `TextFeatureRenderer.Content.Text(x, y, seq, dropShadow=false, color, background, 0)`. - `TextFeatureRenderer.renderText` → `Font.prepareText(seq, x, y, color, dropShadow, …, backgroundColor)` → `Font.PreparedTextBuilder.accept`: styled `BakedGlyph`s (bold copy at `getBoldOffset`, advance `getAdvance(bold)`), strikethrough and underline effects, and `markBackground(x, y, advance)`: left `x - 1`, top `y - 1`, right `x + advance`, bottom `y + 9`. - `Font.width(FormattedText)` = `Mth.ceil(StringSplitter.stringWidth(text))`. - Assets: `font/include/default.json` puts `й`/`Й` (U+0439/U+0419) only in `accented.png` (row 13, columns 5/4; `height` 12, `ascent` 10, 144x900 sheet → 9x12 cells), not in `nonlatin_european.png`. Read from the pinned 26.3 client jar with `javap -c -p`. No harness covers name tag geometry; the new unit test `hud::tests::name_tags_draw_bold_text_and_tall_glyphs_like_any_text` checks the layout. It fails on main's algorithm (`[-6.0, 0.0, 2.0, 8.0] != [-7.6, -0.1, 0.6, 8.1]`: an 8x8 cell, no bold) and passes with the fix. ## Self-check Run on Windows (`tools/pr_ready.py` and `tools/parity.py` don't run on Windows: `signal.SIGHUP`), so these were run by hand: ``` cargo fmt --all -- --check ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings ok cargo test -p horizon-client --features mods --lib --bins --tests --no-fail-fast lib 1109 passed, 1 failed (save::tests::session_lock_is_exclusive: Windows-only, save.rs untouched) bin 139, horizon-ctl 18, integration 10: all passed cargo test -p horizon-client --lib name_tags_draw ok (fails on main's algorithm) ``` ## Screenshots Armor-stand holograms in a creative world (`--in-frame`), `lang:ru_ru`: `{text:'BUILDBATTLE',color:'yellow',bold:true}`, `Онлайн режима: 173`, `Нажмите, чтобы играть`, and bold red `Важно для вашей безопасности!!!`. Before (main; same output on macOS with 0.2.97, where the report came from): BUILDBATTLE and the red line aren't bold, and "й" is squeezed into the line height. ![Before](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/name-tags-before.png) After: bold lines are bold, "й" has its breve above the line as in vanilla, and the background is one pixel taller (vanilla's `y + 9`). ![After](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/name-tags-after.png) Note: holograms summoned in the default server-thread single player didn't show their names at all on main (the client's armor stands had neither the custom name nor `Invisible`/`Marker`), so these shots use `--in-frame`. That's a separate sync gap and isn't touched here. Holograms from a real server, as in the report, do show. ## Rebased on main after #3186 Rebased on main after #3186, re-checked on Windows 11: `cargo fmt --all -- --check` ok; `cargo clippy -p horizon-client-render --all-targets -- -D warnings` and `cargo clippy -p horizon-client --features mods --all-targets -- -D warnings` ok; `cargo test -p horizon-client-render --lib hud::` 16 passed (including `name_tags_draw_bold_text_and_tall_glyphs_like_any_text`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:09:15 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4966
No description provided.