fix(ui): faux bold thickens every glyph, its winding read contour by contour (as FreeType), not thins some #3153

Merged
HumanBean merged 2 commits from cuecuemoar/Longshot:fix/faux-bold-winding into main 2026-12-04 06:50:15 +00:00
Contributor

Summary

The UI's faux bold (the bold of a font with no bold of its own: Windows' CJK, Arabic and Hebrew system fonts) draws some glyphs thinner than regular instead of thicker. Seen in the Korean Insert menu's bold section headings with #3152: "해상도 및 업스케일링" and "프레임 생성 및 지연" draw 업 and 프 thin and dark between bold letters (on main itself Korean has no font yet, #3075).

Outline::embolden (game/crates/ui/src/atlas.rs, FreeType's FT_Outline_EmboldenXY as swash ported it) takes the direction to move a glyph's contours out from its winding, the sign of its area. It took that area over all the glyph's points as one polygon, so the jumps from one contour to the next were counted as edges: for some glyphs they outweigh the contours and flip the sign, and every contour is moved in. Malgun Gothic at 20 px: 업 (glyph 2038) +46.6 as one polygon against −197.1 for its contours, 프 (2830) +10.0 against −148.7; glyphs whose sign stays right were unaffected.

The winding is now the sum of each contour's own area, as FreeType's FT_Outline_Get_Orientation takes it.

Read first: game/crates/ui/src/atlas.rs Outline::embolden and Outline::contours.

Found while on #3075 (#3152); it does not need it, but Korean shows it best with it.

Testing

Tested: Windows 10, RTX 4090, driver 617.42, 2560x1440; Game language Korean, Menu language Auto, Insert menu, Graphics tab. With #3152 alone (5e6cb633c's code): in the two orange headings 업 and 프 are thin and dark. With #3152 and this fix (88492d722: this PR's fix commit on #3152's head, the same fix code as this head; this head adds the second test only): both are as bold and bright as their neighbours. No fault in the run's log. Screenshots: in the comment below.

Checks (Linux, WSL Ubuntu 22.04):

  • cargo test -p game-ui --lib atlas::: on the test commit ced3d2845 faux_bold_moves_a_glyphs_contours_out_when_its_contours_together_wind_the_other_way fails (contour 0 grows (moved out): (4.0, 4.0) -> (2.0, 2.0): a square and a bar, each wound clockwise, whose points as one polygon wind the other way); on 7d738519e it passes, and the whole crate: 175 passed, 0 failed. faux_bold_grows_a_glyph_and_shrinks_its_hole_whichever_contour_comes_first (a hole listed before its outer contour) holds the winding to the contours' sum, not the first contour's.
  • cargo fmt --check clean; cargo clippy -p game-ui -- -D warnings clean.
  • The whole suite --strict on 7d738519e against main ca830e895: 843 passed, 42 failed, 13 skipped on both, the same 42 files (they fail on main in this WSL).
  • A cold review by a second agent (the diff and the test, against FreeType's orientation and embolden): nothing blocking; its hole case is the second test.

Still to test:

  • None. Not run in the game on main alone (its Korean has no font, #3075); the changed code is the rasteriser's, the same with or without #3152.

Measurements

Nothing on the frame path: the area is summed when a bold glyph is first rasterised into the atlas, before its mask is made.

Risks

A faux-bold glyph that was drawn thin is drawn bold; the others are the same as before. A revert is enough. Nothing changes in saves or settings.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Screenshots of the same spot on main and here, for a change that shows on screen.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VxeaZksJ2byiSpsd2k2YbY

## Summary The UI's faux bold (the bold of a font with no bold of its own: Windows' CJK, Arabic and Hebrew system fonts) draws some glyphs thinner than regular instead of thicker. Seen in the Korean Insert menu's bold section headings with https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3152: "해상도 및 업스케일링" and "프레임 생성 및 지연" draw 업 and 프 thin and dark between bold letters (on `main` itself Korean has no font yet, #3075). `Outline::embolden` (`game/crates/ui/src/atlas.rs`, FreeType's `FT_Outline_EmboldenXY` as swash ported it) takes the direction to move a glyph's contours out from its winding, the sign of its area. It took that area over all the glyph's points as one polygon, so the jumps from one contour to the next were counted as edges: for some glyphs they outweigh the contours and flip the sign, and every contour is moved in. Malgun Gothic at 20 px: 업 (glyph 2038) +46.6 as one polygon against −197.1 for its contours, 프 (2830) +10.0 against −148.7; glyphs whose sign stays right were unaffected. The winding is now the sum of each contour's own area, as FreeType's `FT_Outline_Get_Orientation` takes it. Read first: `game/crates/ui/src/atlas.rs` `Outline::embolden` and `Outline::contours`. Found while on #3075 (#3152); it does not need it, but Korean shows it best with it. ## Testing **Tested:** Windows 10, RTX 4090, driver 617.42, 2560x1440; Game language Korean, Menu language Auto, Insert menu, Graphics tab. With #3152 alone (5e6cb633c's code): in the two orange headings 업 and 프 are thin and dark. With #3152 and this fix (88492d722: this PR's fix commit on #3152's head, the same fix code as this head; this head adds the second test only): both are as bold and bright as their neighbours. No fault in the run's log. Screenshots: in the comment below. Checks (Linux, WSL Ubuntu 22.04): - `cargo test -p game-ui --lib atlas::`: on the test commit ced3d2845 `faux_bold_moves_a_glyphs_contours_out_when_its_contours_together_wind_the_other_way` fails (`contour 0 grows (moved out): (4.0, 4.0) -> (2.0, 2.0)`: a square and a bar, each wound clockwise, whose points as one polygon wind the other way); on 7d738519e it passes, and the whole crate: 175 passed, 0 failed. `faux_bold_grows_a_glyph_and_shrinks_its_hole_whichever_contour_comes_first` (a hole listed before its outer contour) holds the winding to the contours' sum, not the first contour's. - `cargo fmt --check` clean; `cargo clippy -p game-ui -- -D warnings` clean. - The whole suite `--strict` on 7d738519e against `main` ca830e895: 843 passed, 42 failed, 13 skipped on both, the same 42 files (they fail on `main` in this WSL). - A cold review by a second agent (the diff and the test, against FreeType's orientation and embolden): nothing blocking; its hole case is the second test. **Still to test:** - None. Not run in the game on `main` alone (its Korean has no font, #3075); the changed code is the rasteriser's, the same with or without #3152. ## Measurements Nothing on the frame path: the area is summed when a bold glyph is first rasterised into the atlas, before its mask is made. ## Risks A faux-bold glyph that was drawn thin is drawn bold; the others are the same as before. A revert is enough. Nothing changes in saves or settings. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Screenshots of the same spot on `main` and here, for a change that shows on screen. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VxeaZksJ2byiSpsd2k2YbY
Two clockwise contours (a square, a long bar above it) whose points, read as
one polygon, wind counter-clockwise: the jumps between the contours add area.
Faux bold must still grow both contours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxeaZksJ2byiSpsd2k2YbY
fix(ui): faux bold thickens every glyph, its winding read contour by contour (as FreeType), not thins some (Hangul 업, 프 in bold headings)
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 8s
7d738519ee
Faux bold decided which way is out from the signed area of all the glyph's
points taken as one polygon. The jumps from one contour to the next add area
of their own, and in some glyphs (Malgun Gothic's 업 and 프) enough to flip the
sign: every contour then moved in, and the bold glyph drew thinner and fainter
than the regular one. The winding is now the sum of each closed contour's own
area, as FreeType's FT_Outline_Get_Orientation reads it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxeaZksJ2byiSpsd2k2YbY
Author
Contributor

Tested in game: Windows 10, RTX 4090, driver 617.42, 2560x1440; Game language Korean, Insert menu, Graphics tab, with #3152 applied (Korean needs its fonts). #3152 alone: the bold headings draw 업 and 프 thin and dark. With this fix on top (88492d722, the same fix code as this head): both bold like their neighbours; no fault in the log.

Tested in game: Windows 10, RTX 4090, driver 617.42, 2560x1440; Game language Korean, Insert menu, Graphics tab, with #3152 applied (Korean needs its fonts). #3152 alone: the bold headings draw 업 and 프 thin and dark. With this fix on top (88492d722, the same fix code as this head): both bold like their neighbours; no fault in the log.
Author
Contributor

Screenshots: Windows 10, RTX 4090, 2560x1440; Game language Korean, Menu language Auto, Insert menu, Graphics tab, with #3152 applied (Korean has no font on main alone).

Before (#3152 alone, 5e6cb633c's code): in the orange headings, 업 in "해상도 및 업스케일링" and 프 in "프레임 생성 및 지연" are thin and dark.

before: #3152 alone

After (#3152 and this fix, 88492d722): both as bold as their neighbours.

after: with this fix

Screenshots: Windows 10, RTX 4090, 2560x1440; Game language Korean, Menu language Auto, Insert menu, Graphics tab, with #3152 applied (Korean has no font on `main` alone). Before (#3152 alone, 5e6cb633c's code): in the orange headings, 업 in "해상도 및 업스케일링" and 프 in "프레임 생성 및 지연" are thin and dark. ![before: #3152 alone](https://git.magicbean.dev/attachments/37eeebd0-9b04-439a-92d7-f13420bf0779) After (#3152 and this fix, 88492d722): both as bold as their neighbours. ![after: with this fix](https://git.magicbean.dev/attachments/a994f71f-9ba7-46be-9caf-bd159857071c)
cuecuemoar changed title from WIP: fix(ui): faux bold thickens every glyph, its winding read contour by contour (as FreeType), not thins some to fix(ui): faux bold thickens every glyph, its winding read contour by contour (as FreeType), not thins some 2026-12-04 04:34:42 +00:00
Owner
@review
BeanBot left a comment

Recommendation: Approve. The contour-by-contour winding fixes the demonstrated faux-bold defect, and the reported game run and regression test support the fix. CI is still running. Nothing blocking is left. Recommend approval; not approved on the forge.

Faux-bold glyphs whose contour jumps previously reversed the winding can now thicken correctly. The change adds a small allocation when a bold glyph is rasterised and keeps the existing atlas and rendering paths.

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes. The author reports that two Korean glyphs were thin before and bold after the fix in the same Windows menu; the game-free regression test reportedly fails on the base and passes on this head.

Other systems: The changed rasteriser is shared by UI text and canvas text on Windows and Linux, regardless of GPU. It affects fonts that require synthetic bold; fonts with a real bold face do not use this path. The reported visual run used Windows and Malgun Gothic; the synthetic outline tests cover the winding logic independently of a font.

Switches: None.

Reviewed: 7d738519ee against ca830e8959: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the screenshot maintenance rules, both commits, the full atlas.rs change and surrounding implementation. Traced text and canvas callers. The referenced Tooling AGENTS.md was unavailable locally; docs/review-checklist.md does not exist. Screenshot attachments could not be inspected from the closed network.; nothing run (a code review).

Checked and fine:

  • Contour ranges follow the point counts emitted by the outline pen, including quadratic and cubic curves.
  • The regression test exercises the reversed aggregate winding and would fail with the old calculation; the second test covers a hole preceding its outer contour.
  • The changed code introduces no shared mutable state, file operations, switches, generated files, or game-derived assets.
  • Both commits record AI assistance.

Testing: No code or tests were run during review. The author reports 175 passing UI crate tests, a failing-before/passing-after regression test, and a successful in-game comparison; CI remains in progress.

Overlaps and merge order: The reported visual comparison uses #3152 to supply Korean fonts; this fix does not depend on merging it. No other overlap was established.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The contour-by-contour winding fixes the demonstrated faux-bold defect, and the reported game run and regression test support the fix. CI is still running. Nothing blocking is left. Recommend approval; not approved on the forge. Faux-bold glyphs whose contour jumps previously reversed the winding can now thicken correctly. The change adds a small allocation when a bold glyph is rasterised and keeps the existing atlas and rendering paths. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. The author reports that two Korean glyphs were thin before and bold after the fix in the same Windows menu; the game-free regression test reportedly fails on the base and passes on this head. **Other systems:** The changed rasteriser is shared by UI text and canvas text on Windows and Linux, regardless of GPU. It affects fonts that require synthetic bold; fonts with a real bold face do not use this path. The reported visual run used Windows and Malgun Gothic; the synthetic outline tests cover the winding logic independently of a font. **Switches:** None. **Reviewed:** 7d738519eeb9 against ca830e895926: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the screenshot maintenance rules, both commits, the full atlas.rs change and surrounding implementation. Traced text and canvas callers. The referenced Tooling AGENTS.md was unavailable locally; docs/review-checklist.md does not exist. Screenshot attachments could not be inspected from the closed network.; nothing run (a code review). **Checked and fine:** - Contour ranges follow the point counts emitted by the outline pen, including quadratic and cubic curves. - The regression test exercises the reversed aggregate winding and would fail with the old calculation; the second test covers a hole preceding its outer contour. - The changed code introduces no shared mutable state, file operations, switches, generated files, or game-derived assets. - Both commits record AI assistance. **Testing:** No code or tests were run during review. The author reports 175 passing UI crate tests, a failing-before/passing-after regression test, and a successful in-game comparison; CI remains in progress. **Overlaps and merge order:** The reported visual comparison uses #3152 to supply Korean fonts; this fix does not depend on merging it. No other overlap was established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch fix/faux-bold-winding 2026-12-04 06:50:16 +00:00
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 8s
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot!3153
No description provided.