[PR #2066] [CLOSED] Font: menus keep their run-time glyphs when the renderer rebuilds its atlas #3977

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2066
Author: @kohad1ck
Created: 10/26/2026
Status: ❌ Closed

Base: main ← Head: fix/font-glyphs-lost-on-atlas-rebuild


📝 Commits (1)

  • 7514254 Font: menus keep their run-time glyphs when the renderer rebuilds its atlas

📊 Changes

2 files changed (+39 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/font.rs (+25 -0)
📝 crates/horizon-client/src/game.rs (+14 -0)

📄 Description

What and why

Fixes #1824, fixes #2040.

With Chinese or Japanese selected, the main-menu labels render and then go blank about two seconds after the title appears, when the game stutters once; Latin text such as Minecraft Realms stays. The same thing showed up on the options screen as half-missing labels (在线选项… drawn as 在线 …, the issue's Japanese screenshots the same).

Characters the bitmap sheets do not cover (unifont provides them) are rasterized into a reserve of the shared GUI atlas at run time, and the font caches the atlas rect it was given. The loading screen hands over to the game by building a new renderer, and that renderer's atlas texture is created from HudAtlas.pixels alone, which never holds a run-time glyph. The cache still answers with the rects it drew into the previous texture, so every character already drawn there disappears; characters first drawn after the handoff are placed into the new texture and show up, which is why the loss looks partial. A resource reload (installing or enabling a pack) creates a fresh font, so it made the text come back until the next launch.

build_renderer and loading_renderer now forget the font's glyph cache before the new texture exists, so the characters drawn again are placed into it. This is what ui_theme already does when its atlas changes (reset_atlas); the font was missing the equivalent. No vanilla behaviour is involved, and Latin text is unaffected either way.

Vanilla reference

None (Horizon's renderer lifetime). Vanilla's FontManager reloads the glyph providers together with the atlases; Horizon keeps one GUI atlas texture for the whole process, so a rebuilt texture has to start with the font's cache cold.

Self-check

python3 tools/pr_ready.py --base upstream/main (against upstream/main at 57c5f8129, 4 min):

Check Result
Scope 2 files, +39 −0
Cargo.lock unchanged
Public tree pass
Python tests no Python change
rustfmt pass
clippy pass
tests: horizon-client 1142 passed, 2 failed
doc tests 0 passed
tokens.css / launcher checks untouched
Parity not run (no vanilla data here): CI's parity job picks the affected harnesses

The two failures are in modules this change does not touch and are environment-specific: crash::tests::stacks_start_at_the_panicking_frame sees the binary's build paths (/src/crash.rs) instead of crates/horizon-client/src/crash.rs, and save::tests::session_lock_is_exclusive hits Windows error 33 (另一个程序已锁定文件的一部分) on its lock file. font::tests::a_rebuilt_atlas_gets_its_glyphs_again (new) passes.

Screenshots

Before (from #1824, v0.2.57, zh_cn): the Singleplayer, Multiplayer, Options and Quit labels are gone after the stutter; Latin Minecraft Realms and the footer remain.

After (release build of this branch, zh_cn, GUI scale 3, no resource packs, started without a control socket so the loading screen hands over as usual; log: loading the title artwork after 1311 ms, world renderer ready after 5770 ms): the title screen reads 单人游戏 / 多人游戏 / Minecraft Realms / 选项… / 退出游戏, and the options screen shows the full 在线选项… that the issue's screenshot had cut down to 在线 ….

Verified by starting the client, letting the handoff happen, and opening Options afterwards.


🔄 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/2066 **Author:** [@kohad1ck](https://github.com/kohad1ck) **Created:** 10/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/font-glyphs-lost-on-atlas-rebuild` --- ### 📝 Commits (1) - [`7514254`](https://github.com/horizon-rust/horizon/commit/7514254bfe1775708094078144ecdf5c333e0949) Font: menus keep their run-time glyphs when the renderer rebuilds its atlas ### 📊 Changes **2 files changed** (+39 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/font.rs` (+25 -0) 📝 `crates/horizon-client/src/game.rs` (+14 -0) </details> ### 📄 Description ## What and why Fixes #1824, fixes #2040. With Chinese or Japanese selected, the main-menu labels render and then go blank about two seconds after the title appears, when the game stutters once; Latin text such as `Minecraft Realms` stays. The same thing showed up on the options screen as half-missing labels (`在线选项…` drawn as `在线 …`, the issue's Japanese screenshots the same). Characters the bitmap sheets do not cover (`unifont` provides them) are rasterized into a reserve of the shared GUI atlas at run time, and the font caches the atlas rect it was given. The loading screen hands over to the game by building a new renderer, and that renderer's atlas texture is created from `HudAtlas.pixels` alone, which never holds a run-time glyph. The cache still answers with the rects it drew into the *previous* texture, so every character already drawn there disappears; characters first drawn after the handoff are placed into the new texture and show up, which is why the loss looks partial. A resource reload (installing or enabling a pack) creates a fresh font, so it made the text come back until the next launch. `build_renderer` and `loading_renderer` now forget the font's glyph cache before the new texture exists, so the characters drawn again are placed into it. This is what `ui_theme` already does when its atlas changes (`reset_atlas`); the font was missing the equivalent. No vanilla behaviour is involved, and Latin text is unaffected either way. ## Vanilla reference None (Horizon's renderer lifetime). Vanilla's `FontManager` reloads the glyph providers together with the atlases; Horizon keeps one GUI atlas texture for the whole process, so a rebuilt texture has to start with the font's cache cold. ## Self-check `python3 tools/pr_ready.py --base upstream/main` (against upstream/main at `57c5f8129`, 4 min): | Check | Result | | --- | --- | | Scope | 2 files, +39 −0 | | Cargo.lock | unchanged | | Public tree | pass | | Python tests | no Python change | | rustfmt | pass | | clippy | pass | | tests: horizon-client | 1142 passed, 2 failed | | doc tests | 0 passed | | tokens.css / launcher checks | untouched | | Parity | not run (no vanilla data here): CI's parity job picks the affected harnesses | The two failures are in modules this change does not touch and are environment-specific: `crash::tests::stacks_start_at_the_panicking_frame` sees the binary's build paths (`/src/crash.rs`) instead of `crates/horizon-client/src/crash.rs`, and `save::tests::session_lock_is_exclusive` hits Windows error 33 (`另一个程序已锁定文件的一部分`) on its lock file. `font::tests::a_rebuilt_atlas_gets_its_glyphs_again` (new) passes. ## Screenshots Before (from #1824, v0.2.57, `zh_cn`): the Singleplayer, Multiplayer, Options and Quit labels are gone after the stutter; Latin `Minecraft Realms` and the footer remain. After (release build of this branch, `zh_cn`, GUI scale 3, no resource packs, started without a control socket so the loading screen hands over as usual; log: `loading the title artwork after 1311 ms`, `world renderer ready after 5770 ms`): the title screen reads `单人游戏` / `多人游戏` / `Minecraft Realms` / `选项…` / `退出游戏`, and the options screen shows the full `在线选项…` that the issue's screenshot had cut down to `在线 …`. Verified by starting the client, letting the handoff happen, and opening Options afterwards. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:13:44 +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#3977
No description provided.