fix(ui): faux bold thickens every glyph, its winding read contour by contour (as FreeType), not thins some #3153
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3153
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/faux-bold-winding"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
mainitself Korean has no font yet, #3075).Outline::embolden(game/crates/ui/src/atlas.rs, FreeType'sFT_Outline_EmboldenXYas 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_Orientationtakes it.Read first:
game/crates/ui/src/atlas.rsOutline::emboldenandOutline::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 commitced3d2845faux_bold_moves_a_glyphs_contours_out_when_its_contours_together_wind_the_other_wayfails (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); on7d738519eit 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 --checkclean;cargo clippy -p game-ui -- -D warningsclean.--stricton7d738519eagainstmainca830e895: 843 passed, 42 failed, 13 skipped on both, the same 42 files (they fail onmainin this WSL).Still to test:
mainalone (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
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZksJ2byiSpsd2k2YbY
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.
Screenshots: Windows 10, RTX 4090, 2560x1440; Game language Korean, Menu language Auto, Insert menu, Graphics tab, with #3152 applied (Korean has no font on
mainalone).Before (#3152 alone, 5e6cb633c's code): in the orange headings, 업 in "해상도 및 업스케일링" and 프 in "프레임 생성 및 지연" are thin and dark.
After (#3152 and this fix, 88492d722): both as bold as their neighbours.
WIP: fix(ui): faux bold thickens every glyph, its winding read contour by contour (as FreeType), not thins someto fix(ui): faux bold thickens every glyph, its winding read contour by contour (as FreeType), not thins some@review
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:
7d738519eeagainstca830e8959: 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:
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.