[PR #1879] [MERGED] Legacy § codes render in name tags and styled labels #3836

Closed
opened 2026-11-03 04:12:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1879
Author: @socksprox
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @ludovic111

Base: main ← Head: fix/legacy-colour-codes


📝 Commits (1)

  • 72b9daa Resolve legacy § codes where the font draws text

📊 Changes

5 files changed (+50 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/font.rs (+4 -1)
📝 crates/horizon-client/src/game/names.rs (+8 -4)
📝 crates/horizon-client/src/hud.rs (+3 -0)
📝 crates/horizon-client/src/text.rs (+25 -0)
📝 crates/horizon-client/src/ui.rs (+10 -2)

📄 Description

🤖 Opened by socksprox's AI agent (Devin), not by socksprox himself.

What and why

Text a server styles with legacy § codes now renders in colour, as vanilla's font does, in two places players reported:

  • Name tags. A team prefix or custom name holding a literal §c drew as "§cSteve" over players' heads (the § as a missing glyph, the code as a character). name_tags now resolves the codes on the shown name and the below-name score, so "§cSteve" draws "Steve" in red — mobs, players and armour-stand holograms alike. The control socket's state reports the resolved names.
  • The leave-server button — and every styled label. A server resource pack that overrides menu.disconnect with styled text kept its § codes on the button. HudBatch::text_styled (the Font.drawInternal port), Font::width_text and ui::centered_text resolve codes inside span contents, so every HUD/menu label measures and draws the way vanilla's font does — § sequences restyle what follows and produce no glyphs and no width.

Text::resolved() is the borrowing form of resolve_legacy() for these per-frame paths: it scans for § first and borrows the text when there is none. Callers that already resolved upstream are unaffected — resolution is idempotent.

Related open work (not duplicated): #1841 puts the team-formatted name into chat senders; #1741 keeps styled menu titles. This covers the name tag above the entity and the pause menu's buttons.

Vanilla reference

  • StringDecomposer.iterateFormatted: a § plus a code character inside a component's contents restyles what follows (a colour clears the decorations, §r returns to the span's own style); the pair never reaches a glyph. Font.drawInternal and Font.width both go through it.
  • EntityRenderer.submitNameTag / PlayerTeam.formatNameForTeam: the prefix + name + suffix component drawn through that font.
  • ClientboundUpdateTeamsPacket prefixes and server-pack lang overrides are the components where the codes arrive.

No dedicated harness exists for name-tag or pause-menu text; the change sits in paths shared by the affected harnesses (CI's parity job picks them up: 339 depend on the touched files). A lib test pins resolved()'s restyle-and-borrow behaviour.

Self-check

pr_ready (tools/pr_ready.py --quick on MacBookPro, against origin/main at 5115bc276, 21 s)

Check Result
Scope ✅ 5 files, +50 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (5 s)
clippy ✅ (1 s)
tests: horizon-client ✅ 1239 passed (13 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Devin


🔄 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/1879 **Author:** [@socksprox](https://github.com/socksprox) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/legacy-colour-codes` --- ### 📝 Commits (1) - [`72b9daa`](https://github.com/horizon-rust/horizon/commit/72b9daabf01ee530be04b6dba5f3f58fe9ef2410) Resolve legacy § codes where the font draws text ### 📊 Changes **5 files changed** (+50 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/font.rs` (+4 -1) 📝 `crates/horizon-client/src/game/names.rs` (+8 -4) 📝 `crates/horizon-client/src/hud.rs` (+3 -0) 📝 `crates/horizon-client/src/text.rs` (+25 -0) 📝 `crates/horizon-client/src/ui.rs` (+10 -2) </details> ### 📄 Description > 🤖 Opened by socksprox's AI agent (Devin), not by socksprox himself. ## What and why Text a server styles with legacy `§` codes now renders in colour, as vanilla's font does, in two places players reported: - **Name tags.** A team prefix or custom name holding a literal `§c` drew as "§cSteve" over players' heads (the `§` as a missing glyph, the code as a character). `name_tags` now resolves the codes on the shown name and the below-name score, so "§cSteve" draws "Steve" in red — mobs, players and armour-stand holograms alike. The control socket's `state` reports the resolved names. - **The leave-server button** — and every styled label. A server resource pack that overrides `menu.disconnect` with styled text kept its `§` codes on the button. `HudBatch::text_styled` (the `Font.drawInternal` port), `Font::width_text` and `ui::centered_text` resolve codes inside span contents, so every HUD/menu label measures and draws the way vanilla's font does — `§` sequences restyle what follows and produce no glyphs and no width. `Text::resolved()` is the borrowing form of `resolve_legacy()` for these per-frame paths: it scans for `§` first and borrows the text when there is none. Callers that already resolved upstream are unaffected — resolution is idempotent. Related open work (not duplicated): #1841 puts the team-formatted name into chat senders; #1741 keeps styled menu *titles*. This covers the name tag above the entity and the pause menu's buttons. ## Vanilla reference - `StringDecomposer.iterateFormatted`: a `§` plus a code character inside a component's contents restyles what follows (a colour clears the decorations, `§r` returns to the span's own style); the pair never reaches a glyph. `Font.drawInternal` and `Font.width` both go through it. - `EntityRenderer.submitNameTag` / `PlayerTeam.formatNameForTeam`: the prefix + name + suffix component drawn through that font. - `ClientboundUpdateTeamsPacket` prefixes and server-pack `lang` overrides are the components where the codes arrive. No dedicated harness exists for name-tag or pause-menu text; the change sits in paths shared by the affected harnesses (CI's parity job picks them up: 339 depend on the touched files). A lib test pins `resolved()`'s restyle-and-borrow behaviour. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on MacBookPro, against origin/main at 5115bc276, 21 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +50 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 s) | | tests: horizon-client | ✅ 1239 passed (13 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Devin](https://devin.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:12:40 +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#3836
No description provided.