Skip to content

fix(text): follow up on the merged text pull requests - #2483

Open
houko wants to merge 8 commits into
mainfrom
fix/followup-ui-input-text-3
Open

houko wants to merge 8 commits into
mainfrom
fix/followup-ui-input-text-3

Conversation

@houko

@houko houko commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Follow-up review of the l10n and text pull requests the merge train landed on 2026-11-29, checked against current main.

#2312 feat(l10n): add CSV exchange helpers

Landed intact. Problems: ImportCSV let a second row with the same key silently replace the first, and accepted empty keys and repeated, empty or non-canonical locale columns; ValidatePlaceholders only checked that source placeholders survived (a translation adding {bonus} passed), counted {{/}} escapes as placeholders unlike StripPlaceholders/Catalog.T, and reported a map-order-dependent placeholder first. The test only read one cell back.

This PR: ImportCSV refuses those tables with the CSV line, ExportCSV refuses an empty key or a bad locale column, ValidatePlaceholders requires the same placeholders with the same counts using the StripPlaceholders brace rules and reports in sorted order. Tests cover key order, a byte-stable round trip with quoted and multi-line cells, each refusal and the placeholder rules. #1431 stays open (PO, game l10n, editor are not done; the PR did not claim to close it).

#2349 test: fuzz localization yaml loader

Landed intact (its changelog fragment was folded into the 0.4.0 release). The only non-empty seed had no plurals; this PR also seeds the target from testdata/en.yaml.

#2357 feat(l10n): add template locale selection

Code landed intact; the docs/en and docs/zh l10n.md paragraph was dropped by the merge. Restored under "Choosing a template's locale".

#2379 feat(l10n): add localized asset read helper

Code landed intact; the "Reading localized assets" section was dropped from both l10n.md files. Restored.

#2297 feat(text): add wrapping and overrun helpers

Problems: Ellipsize returned the whole string for OverrunClip (no truncation at all), and OverrunWordEllipsis cut the rune slice at the word boundary and then resliced it back out to max-1 runes, so it behaved exactly like OverrunEllipsis. The Overrun constants had no doc comments and BreakLines claimed Unicode whitespace breaking while it only breaks at space and tab. The merge also nested "Wrapping and overrun" under "Text effects" in text.md.

This PR fixes both modes with table tests (including CJK), documents the constants and corrects the BreakLines comment, and makes the docs heading a section of its own.

#2298 feat(text): add shared text effects contract

Problems: SDFOptions gained Effects next to its own Outline/OutlineColor, so an outline set through the shared contract was silently ignored by the only backend that can draw one; TextEffects fields had no doc comments or units; the test only read back a struct literal. The gameui.md sentence the merge dropped ("Text widgets can carry the shared text.TextEffects style") is not restored because no gameui widget has such a field.

This PR makes SDF drawing use Effects.Outline/OutlineColor when its own outline fields are unset, documents every field, states on Options.Effects and PlatformStyle.Effects that those backends do not draw them yet, and replaces the test with one that checks the resolved SDF style.

#2301 feat: add deterministic font sdf generation

Code landed intact; the docs paragraph landed in the rich-text section and is moved to the SDF fonts section. The PR said "Closes #1421", but it only converts an alpha mask to a single-channel SDF: there is no TrueType/OpenType outline reading, no MSDF, no game assets font sidecar kind, no charsFrom baking and no atlas output. #1421 does not meet its acceptance and should be reopened.

#2310 feat(text): make rich layout grapheme and RTL aware

Problems: reorderRichLine matched the reordered string back to tokens by cluster text. With a repeated letter (Hebrew "אבא") the visually first copy took the logically first token, so the wrong glyph got that token's style and reveal index; any right-to-left line where VisualOrder changes the text (mirrored brackets, a ZWJ sequence reversed rune by rune) failed the match and was silently left in logical order; a line with an inline icon was never reordered. The merge also glued the docs paragraph onto the "Per-language asset catalogs" heading in both l10n.md files.

This PR adds l10n.VisualRuneOrder (the logical rune index at each visual position, from the same bidi pass as VisualOrder; reorderLine is split so both share it) and has rich layout permute tokens by it, take each token's drawn rune from VisualOrder (mirrored brackets), keep a cluster's tokens together and treat an icon as U+FFFC. Tests check reveal indices and style for a repeated letter and the order with brackets; the note gets an amendment. Headings fixed.

Verification

  • go tool nsgo test ./pkg/l10n/... ./pkg/text/... (blackmac): 120 passed
  • go tool nsgo check ./pkg/l10n/... and ./pkg/text/..., go tool nsgo test ./internal/repocheck/..., go run ./tools/changelog check, bun run verify-notes

The commit "fix(l10n): refuse ambiguous CSV tables and extra placeholders" appears twice; the second one (only yaml_fuzz_test.go) is the fuzz seed change.

Screenshots: None

…ed headings

The merge train dropped the TemplateLocale (#2357) and AssetCatalog.Read (#2379) paragraphs from docs/en and docs/zh l10n.md, glued the rich-text direction paragraph (#2310) onto the "Per-language asset catalogs" heading, and left the MirrorRect paragraph under "CSV exchange". In text.md the GenerateSDF paragraph (#2301) landed in the rich-text section and "Wrapping and overrun" (#2297) became a subsection of "Text effects".
…oundary

Ellipsize returned the whole string for OverrunClip, and OverrunWordEllipsis cut the rune slice at the word boundary and then resliced it back out to max-1 runes, so it gave the same result as OverrunEllipsis. Both now honour the limit, with table tests for every mode and CJK input. The Overrun constants get doc comments and BreakLines describes what it breaks at.
…contract

SDFOptions gained an Effects field next to its own Outline and OutlineColor, so an outline set through the shared contract was silently ignored by the one backend that can draw it. SDF drawing now uses Effects.Outline and OutlineColor when its own outline fields are unset, TextEffects fields get doc comments with units, and the Effects fields on Options and PlatformStyle say that those backends do not draw them yet. The previous test only read back a struct literal; it now checks the SDF style the options resolve to.
…h text

reorderRichLine matched the bidi-reordered string back to tokens by cluster text, so a line that repeats a letter gave the visual-first copy the logical-first token (wrong reveal index and style), and any right-to-left line with a mirrored bracket or a reversed ZWJ sequence failed the match and was silently left in logical order. A line with an inline icon was never reordered.

l10n gains VisualRuneOrder, which returns the logical rune index at each visual position from the same bidi pass as VisualOrder, and rich layout now permutes tokens by it, draws mirrored brackets as VisualOrder does, keeps the tokens of one grapheme cluster together, and treats an icon as U+FFFC.
ImportCSV let a later row with the same key silently replace an earlier one and accepted repeated, empty or non-canonical locale columns and empty keys; it now refuses them with the CSV line. ValidatePlaceholders only checked that the source placeholders survived, treated "{{" escapes as placeholders and reported a random one first; it now requires the same placeholders with the same counts, follows the StripPlaceholders brace rules and reports in sorted order. The tests cover sorting, a byte-stable round trip with quoted and multi-line cells, and each refusal.
ImportCSV let a later row with the same key silently replace an earlier one and accepted repeated, empty or non-canonical locale columns and empty keys; it now refuses them with the CSV line. ValidatePlaceholders only checked that the source placeholders survived, treated "{{" escapes as placeholders and reported a random one first; it now requires the same placeholders with the same counts, follows the StripPlaceholders brace rules and reports in sorted order. The tests cover sorting, a byte-stable round trip with quoted and multi-line cells, and each refusal.
@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation pkg/l10n pkg/text area/agents size/L labels Nov 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agents bug Something isn't working documentation Improvements or additions to documentation pkg/l10n pkg/text size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text: generate SDF and MSDF font atlases from TrueType and OpenType in game assets

1 participant