Repository navigation
words: Thai lines break between words in blocks-desktop (#306) - #318
Merged
Merged
Conversation
…egui wraps at (#306) docs/architecture/thai/: the ADR, the callers' usage, the shapes, boundaries and statechart, and what was measured. egui keeps wrapping; a words module in blocks-desktop takes Thai word boundaries from icu_segmenter's dictionary, puts a zero-width space egui may break at on each, and drops them from the laid galley, so its text is the caller's. Text with no Thai is egui's own. proto/ is two throwaway crates outside every workspace; look/ has its shot at 390.
…and the composer through it (#306)
…patch time is reported (#306)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #306
For humans
Thai text in the desktop app now wraps between words instead of in the middle of a word: plain text, formatted paragraphs and links, list rows, cards, chat messages, tool output and the message box you type in.
Text with no Thai in it is drawn exactly as before, pixel for pixel.
The desktop app grows by about 1.1 MB, for the Thai word list the line breaking needs.
For apps: nothing to do. Thai wraps between words in every core kind on the desktop. An app's own kinds and islands that draw text with their own egui calls get the same by calling
blocks_desktop::words::label(orsensing,link, andlayfor a text field's layouter). Release binaries grow by about 1.1 MB (icu_segmenter's bundled dictionaries).What changed
Built to the approved ADR in
docs/architecture/thai/(#304 has not landed, so kinds callwordsdirectly).crates/blocks-desktop/src/words.rs(new, thedesktop-wordslayer):breaks(ICU4X dictionary line breaks kept only between two Thai characters, not before a mark,ๆ,ฯor a letter carrying์),Soft(a zero-width gap section at each break),harden(gap glyphs dropped, caller's text and sections put back),Kept(cut and hard galley kept per pass in the context's temp data, no lock), and the publiclabel,sensing,link,lay.ui.label((29 calls in 14 files), the card's sensing title and prose's link go throughwords; the composer's multi-row field takeswords::layas its layouter (blocks-desktop: styled look (type scale, spacing, app font) per #299 #303 landed its native composer, so it is covered now).icu_segmenter2.4 (default features off,compiled_dataon) inblocks-desktoponly, with itsdocs/deps.mdline;demo/egui/Cargo.lockupdated..drover/arch.toml: thedesktop-wordslayer and the three bans (icu_segmenter,ui.label(,hyperlink_to() as the ADR lists them; the rules file gets the layer and the one new line (29 of 30)..drover/arch-baseline.txt:arch.toml553 -> 576, the 23 lines of that layer and those bans (as form v2 F4a: upload field, file handler, type and size check, file step, bans (#188) #263 and hotspots 2: web: one file per kind; the table of kinds generated (#152) #201 did for theirs).tests/latin/(a Latin and CJK text, row and card, committed first at the pre-change head as the baseline) andtests/thai/(the sample grown to text, prose with a bold span and a link, row, card, message, tool with its body open, composer with typed Thai, form), each 390 wide in light and dark.Decisions: the composer's layouter rebuilds the job TextEdit's default layouter makes (body font, inactive text colour, its line height, trailing whitespace kept); every fixture's PNG is unchanged, so it matches. The ADR's 230-line estimate did not count the link and sensing paint path (
ink) or that layouter.src/ net +319 (budget +230): words.rs is 289 lines with the link/sensing paint path egui keeps private; call sites +30. Total 43,202 / 44,000.
Evidence at f019dfd
cargo fmt --checkjust clippyjust archjust capjust depsjust denycargo test --locked -p blocks-desktop -p blocks-deskjust desktopcargo test --release -p blocks-desk --test perf -- --ignored --test-threads=1cargo check --lockedindemo/eguithe_probe_line_at_120_points_breaks_only_between_its_wordslaysภาษาไทยไม่มีช่องว่างระหว่างคำat 120 points with the Thai font and holds every row end to the end of one of its eight words; the same test asserts egui alone breaks inside a word, and that at 390 it is one row. Runs in desktop.yml on macOS, Linux and Windows.the_thai_sample_is_the_checked_in_pngs_in_light_and_darkcompares the sample's 390 PNGs byte for byte;the_thai_sample_holds_every_kind_that_wraps_textholds it to text, prose, row, card, message, tool and composer. The PNGs were made on macOS and matched byte for byte on Linux and Windows in CI at 161b560.latin_and_cjk_are_the_checked_in_pngs_in_light_and_darkwas committed with its PNGs at the pre-change head (d21f9a5) and passes unchanged at the head. Beyond it, everyfixtures/blocksandfixtures/stressfile at 390x844 and 1440x900, light and dark, drawn byblocks-deskbefore and after this change: 500 PNGs compared, 0 differ. There is no right-to-left snapshot on staging yet (blocks-desktop: right-to-left and bidi text layout #304 has not landed).Arc::ptr_eq); Thai not wrapped has egui's glyph places and size; a word wider than its line still breaks; a drag over a wrapped Thai label then Copy gives the text without gaps; the composer sends typed Thai unchanged. With hardening disabled, the probe, copy and snapshot tests fail.Perf: the Thai 200-row case holds the 16.7 ms pass budget, as the ADR names it ("a Thai case of the 200-row screen under the same 16.7 ms"); its patch time is reported in the job summary but not held to the Latin screen's 4 ms. On CI at 161b560 the Thai patch was 4.48 ms (Linux) and 4.83 ms (Windows), its pass 4.81 and 6.98 ms. Most of that is egui drawing Thai at all: measured on macOS, a Thai patch is 1.49 ms with
wordsswitched off and 1.71 ms with it, against 1.22 ms for the Latin screen. The Latin case keeps its 4 ms assertion and passes.CI at 161b560: the snapshot, probe and copy tests passed on macOS, Linux and Windows (so the Thai and Latin PNGs are byte-identical across the three); only the Thai patch assertion failed, which this head changes.
Not verified here:
demo/egui's wasm size (no wasm target on this host).