[PR #7550] Fonts: skip a provider glyph whose advance is fishy #7663

Open
opened 2026-11-03 07:21:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7550
Author: @MSedgeMC
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/font-fishy-advance


📝 Commits (3)

  • 32b7825 Fonts: skip a provider glyph whose advance is fishy
  • 6721648 test: a fishy advance falls through to the next provider
  • 1fc91ec port_map: client2-012's fishy advance rows are ports

📊 Changes

2 files changed (+73 additions, -17 deletions)

View changed files

📝 crates/horizon-client-render/src/font.rs (+71 -15)
📝 tools/port_map/client2-012.tsv (+2 -2)

📄 Description

Vanilla

FontSet.computeGlyphInfo does not stop at the first provider that has a character. For each provider it asks hasFishyAdvance — an advance under 0 or over 32, checked on both the baked and the unbaked glyph — and only takes a glyph that passes; a fishy one sends it on to the next provider, and when no provider has a good glyph the character draws the missing glyph. FontSet.getRandomGlyph, which serves obfuscated text, hands out SelectedGlyphs.nonFishy, so a fishy glyph is no candidate there either.

Horizon

Font::resolve returned the first provider's glyph whatever its advance, and provider_advance — which builds the by-width table random_glyph picks from — returned that advance too. A resource pack whose glyph claims an advance of 65 therefore widened every line the character appeared in, and filed that character under the wrong width for obfuscated text, where vanilla falls through to the next provider.

Both now skip a fishy advance. The rule lives in one place (fishy_advance) and covers space, bitmap, unihex and TrueType glyphs; unihex advances come from hex_advance, shared with rasterize_hex so the check and the drawn glyph cannot disagree.

Proven

a_fishy_advance_falls_through_to_the_next_provider (font.rs) builds a font whose first bitmap provider gives a a 65 pixel advance (64 opaque columns) and whose second provider gives it 3:

  • without the change: font.glyph('a').advance is 65.0, font.advance('a', ..) is 65.0, and random_glyph(&Style::default(), 65.0) finds that glyph in the by-width table;
  • with the change: font.glyph('a').advance is 3.0, font.advance('a', ..) is 3.0, and random_glyph(&Style::default(), 65.0).advance is 6.0, the missing glyph.

The ledger rows FontSet.hasFishyAdvance and FontSet.computeGlyphInfo (client2-012) name fishy_advance and lose the gap note.

Not proven

The build VM was unreachable while this was written, so the test has not been run here: CI will run it (cargo test -p horizon-client-render --lib a_fishy_advance). Vanilla's SelectedGlyphs.any, which keeps the fishy glyph for the plain glyph source, has no Horizon counterpart: when every provider is fishy Horizon draws the missing glyph, a case the test does not cover.


🔄 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/7550 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/font-fishy-advance` --- ### 📝 Commits (3) - [`32b7825`](https://github.com/horizon-rust/horizon/commit/32b78254ed7c016527a53db63c13a0eaa780f0af) Fonts: skip a provider glyph whose advance is fishy - [`6721648`](https://github.com/horizon-rust/horizon/commit/67216485b163d3798381ca0445cc5939f1e0d418) test: a fishy advance falls through to the next provider - [`1fc91ec`](https://github.com/horizon-rust/horizon/commit/1fc91ecab81485f8d73d3a437deb89bd6314f369) port_map: client2-012's fishy advance rows are ports ### 📊 Changes **2 files changed** (+73 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/font.rs` (+71 -15) 📝 `tools/port_map/client2-012.tsv` (+2 -2) </details> ### 📄 Description ## Vanilla `FontSet.computeGlyphInfo` does not stop at the first provider that has a character. For each provider it asks `hasFishyAdvance` — an advance under 0 or over 32, checked on both the baked and the unbaked glyph — and only takes a glyph that passes; a fishy one sends it on to the next provider, and when no provider has a good glyph the character draws the missing glyph. `FontSet.getRandomGlyph`, which serves obfuscated text, hands out `SelectedGlyphs.nonFishy`, so a fishy glyph is no candidate there either. ## Horizon `Font::resolve` returned the first provider's glyph whatever its advance, and `provider_advance` — which builds the by-width table `random_glyph` picks from — returned that advance too. A resource pack whose glyph claims an advance of 65 therefore widened every line the character appeared in, and filed that character under the wrong width for obfuscated text, where vanilla falls through to the next provider. Both now skip a fishy advance. The rule lives in one place (`fishy_advance`) and covers space, bitmap, unihex and TrueType glyphs; unihex advances come from `hex_advance`, shared with `rasterize_hex` so the check and the drawn glyph cannot disagree. ## Proven `a_fishy_advance_falls_through_to_the_next_provider` (`font.rs`) builds a font whose first bitmap provider gives `a` a 65 pixel advance (64 opaque columns) and whose second provider gives it 3: - without the change: `font.glyph('a').advance` is `65.0`, `font.advance('a', ..)` is `65.0`, and `random_glyph(&Style::default(), 65.0)` finds that glyph in the by-width table; - with the change: `font.glyph('a').advance` is `3.0`, `font.advance('a', ..)` is `3.0`, and `random_glyph(&Style::default(), 65.0).advance` is `6.0`, the missing glyph. The ledger rows `FontSet.hasFishyAdvance` and `FontSet.computeGlyphInfo` (client2-012) name `fishy_advance` and lose the gap note. ## Not proven The build VM was unreachable while this was written, so the test has not been run here: CI will run it (`cargo test -p horizon-client-render --lib a_fishy_advance`). Vanilla's `SelectedGlyphs.any`, which keeps the fishy glyph for the plain glyph source, has no Horizon counterpart: when every provider is fishy Horizon draws the missing glyph, a case the test does not cover. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7663
No description provided.