Repository navigation
fix(fonts): MTEXT \W…x multiplies the width factor; document the atom cap - #1273
Conversation
…om cap (storytold#1272) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the diff: MTEXT \W...x multiplies the width factor, and the atom cap is documented. The doc comment on the cap now says it counts words, spaces and paragraph breaks per MTEXT, that hostile contents are cut there, and that the rest of the contents is silently dropped from the layout with no warning to the caller (an honest statement of a limitation). The width factor code was num(a.trim_end_matches(['x','X'])).filter(|v| *v > 0.01 && *v < 100.0) with f.wf = v; the new code strips the suffix with strip_suffix(['x', 'X']) to know whether it was relative and, per the comment, \W2x; multiplies the current factor (like \H2x;) and \W2; sets it. That is the MTEXT rule. The range filter on the value (0.01 to 100) should apply to the product too, since repeated \W50x; multiplies the factor beyond any bound, a way to produce a huge layout from a small string; the cap on atoms does not limit that. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
austin62jake
left a comment
There was a problem hiding this comment.
Approving. I merged it onto current main with ten other small PRs (#1273, #1266, #1265, #1263, #1254, #1247, #1233, #1196, #1114, #1445, #1591). The whole suite passes (3170 tests), and so do fmt and the web build. Clippy stops only on #1254's test.
\W2x; multiplying the current width factor, as \H2x; already does for height, while \W2; sets it, matches the MTEXT format. Clamping the compounded factor to the absolute range keeps repeated x codes bounded. Documenting that atoms past the cap are dropped silently is honest.
FredApps
left a comment
There was a problem hiding this comment.
Reviewed 1d29b626e66cc1a06999ba36dfb40e441929b3f6. No findings in the complete one-file source review. My earlier compounding-width concern was incorrect: this head already clamps the product to 0.01..=100.0, and width_factor_x_is_relative covers repeated growth/shrinkage, absolute vs relative assignment, uppercase X and invalid values. The atom-limit documentation accurately describes the existing behavior.
This is a review comment, not an approval: GitHub reports no checks for this head, and no local Rust tests were run because the available workspace is out of disk space. Please refresh the branch onto the current CI-enabled base and obtain a passing gate, or provide reproducible validation for this exact head. The missing validation is the remaining gap; I am not asking for duplicate tests that are already in the diff.
|
CI never ran on this branch since it predates the workflow, so I checked it by hand: merged onto current main ( |
…H…x do (storytold#2827) Main's storytold#1273 made the x suffix of \W relative (\H already was). \T read it as an absolute factor, so \T2;\T1.5x; tracked at 1.5 instead of 3. The product is held to the format's 0.75 to 4. The three size codes now read their argument with one helper, `factor`.
Fixes #1272
Problem
In MTEXT, a trailing
xon the width code (\W2x;) makes the value relative: it multiplies the current width factor (public DXF reference).parsestripped thexand used the number as an absolute factor, so\W2x;set 2 instead of doubling.\H...xwas already correct. Separately, the 200 000-atom cap inparsedropped the rest of an MTEXT without saying so anywhere.Changes
crates/fonts/src/mtext.rs:\W<n>x;multiplies the currentwf;\W<n>;is unchanged (absolute). The compounded result is clamped to 0.01..100, the range an absolute\Walready accepts, so a long relative chain stays finite (same idea as the relative\Hbound).MAX_ATOMSstates that parsing stops after the cap and the rest is silently dropped. Behaviour is unchanged.width_factor_x_is_relative: absolute, relative, relative after absolute, capitalX, 50-step chains up and down (clamped to 100 and 0.01), and1e999,NaN, empty values (ignored).Limits
\W...x.\K,\T,\Aare untouched.docs/for it, so the doc comment is the only place.\W0.005x;) is still ignored, like an absolute one.Test plan
left: 2.0, right: 3.0on the relative case) and passes with it.cargo fmt --check,cargo clippy -p cadcraft-fonts --all-targets -- -D warnings,cargo test -p cadcraft-fonts -p cadcraft-render,cargo xtask layers,cargo check --target wasm32-unknown-unknown -p cadcraft-fonts: all pass.git merge-treeagainst upstream/main, fix(fonts): MTEXT keeps the text after an unterminated code; bound oblique, line spacing and relative heights #1036's branch and MTEXT: keep leading and repeated spaces; read a caret-I in the contents as a tab #950's head: no conflicts.Did not run
cargo xtask ci(whole-workspace clippy/tests, assets, wasm build) and the rest of the workspace tests.🤖 Generated with Claude Code