Repository navigation
Conversation
…he size it draws at Shrink Text to Fit scales area type down at layout time, and the canvas, PDF export and the exports that write type as outlines draw it at that size. SVG export wrote the live text at its stored font size, letter spacing and baseline shift, so a viewer drew it larger than the canvas does. Legacy .ai saves wrote the stored size, leading and baseline shift into the text objects, DXF export took the TEXT heights from the stored size, and the CSS Properties panel gave the stored font size, letter spacing and line height. The text crate's scaled, which the layout scales shrunk text with, is now public. SVG export, legacy .ai saves and the CSS Properties panel take the type's styles from it at the layout's fit scale, and DXF export multiplies the TEXT heights by that scale. Positions and textLength in SVG still come from the layout. Docs: docs/target-app-parity.md.
FredApps
left a comment
There was a problem hiding this comment.
This is a comment, not an approval. I haven't built or run it (no cargo here), and the hosted checks on this head (affinity3, FreeBSD, the two windows-arm64 jobs) all pass but none of them is a workspace test run that I can see, so the five new tests have no hosted result. By my reading I found no blocker.
What I read. The whole diff: text/src/layout.rs (scaled made public), the DXF, legacy .ai, SVG export and CSS writers, and the four new tests.
What I checked, and it holds.
- The idea. Shrink Text to Fit lays out
scaled(t, layout.fit_scale), but the exporters wrote the unscaled styles, so a shrunk area type came out at its full size and overflowed its frame in the target. Each exporter now writes the styles the layout draws in, using the samescaledfunction the layout itself uses, so the two cannot drift apart. - DXF. The cap height is
cs.size * layout.fit_scale * .... The test checks14.0 * fitfor 20 pt type (cap height 0.7 of the size), which is consistent withCAP_HEIGHT. - Legacy
.ai, CSS. Both buildfittedonly forAreaplusShrinkTextand only whenfit_scale != 1.0, and otherwise keep the originalt, so other type and unshrunk type are unchanged. The.aitest checks sizes, baseline shift (3 * fit) and leading (20 * fit) after a read-back, and that the result no longer overflows. - SVG.
drawnreplacestonly for the first style and thetext_linecalls;linesandlaystill come from the original layout, which is what was shrunk. The test runs ragged, centred and both justified modes, plus Fewer<tspan>Elements. - Docs. The parity note matches what is written.
Points for the author and maintainers.
- Layout runs again.
css.rsandlegacy_ai.rscalllayoutjust to getfit_scale, a second full layout (with its shrink search) for each shrunk object. Fine for correctness; if exports of big documents get slower, pass the layout in instead. - Float equality.
fit_scale != 1.0is an exact compare. It is only a shortcut (scaling by 1.0 is a no-op), so no harm. - Rounding. A shrunk size is now an arbitrary number (for example 17.3 pt). That is the true drawn size, but reimporting the SVG or
.aiwill show it, and it is worth a line in the release note. - Hosted tests. Please get the workspace test job run on this head so the five new tests are checked.
Validation request (head d1d9cff876f03ecc60edc452ade02cda6672bbab):
- os: linux
- commands:
cargo fmt --all -- --check;cargo test -p vectorcraft-cad -p vectorcraft-eps -p vectorcraft-svg -p vectorcraft-text - expected: all pass, including
shrunk_area_type_*in cad, eps and svg; an area type with Shrink Text to Fit exports at its drawn size in SVG,.ai, DXF and CSS - holds: I did not run anything; no hosted workspace test result on this head
FredApps
left a comment
There was a problem hiding this comment.
Correction to my review above (same head, d1d9cff8…): I wrote that none of the hosted checks was a workspace test run, so the five new tests had no hosted result. That was wrong. The freebsd / FreeBSD 15 (build + test) job runs cargo test --workspace --locked on this head and passes (about 2,130 tests across the workspace in its log), so the new tests in cad, eps, svg and text were run and are green on FreeBSD.
The rest of my review is unchanged: no blocker, and the points for the author (the second layout pass in the .ai and CSS writers, arbitrary shrunk sizes on re-import) still stand. Only the "no hosted workspace test result" hold is withdrawn.
Messhias
left a comment
There was a problem hiding this comment.
Export: area type that Shrink Text to Fit scales down is written at the size it draws at. Checklist cargo xtask ci is ticked.
What and why
Shrink Text to Fit scales area type down at layout time.
docs/mcp.mdsays "The stored sizes don't change: the scaling happens at layout time, so rendering and every export see it." The canvas, PDF export and the exports that write type as outlines draw the shrunk size, but four writers took their sizes from the stored styles. SVG export wrote 12 pt type that the layout draws at 8 pt asfont-size="12", with the full letter spacing and baseline shift, so a viewer drew it larger than the canvas does.vectorcraft_text::scaled, the function the layout scales shrunk text with, is now public. SVG export, legacy.aisaves and the CSS Properties panel take the type's styles from it at the layout'sfit_scale, and DXF export multiplies itsTEXTheights by that scale.dy) at the drawn size, with and without Fewer<tspan>Elements. Positions andtextLengthstill come from the layout..aisaves write the text objects' size, leading and baseline shift at the drawn size, so the type reads back fitting its frame.TEXTheights at the drawn size, and the CSS Properties panel gives the drawn font size, letter spacing and line height.docs/target-app-parity.mdhas one line for it. No command, reply or user-visible string changes.How it was tested
New tests, each failing on
main:shrunk_area_type_is_written_at_the_size_it_draws_at(vectorcraft-svg,tests/text_layout.rs): usvg draws every character of shrunk area type where the canvas draws it and as wide (tracked, kerned, shifted and larger runs on Left, Center, Justify Left and Justify All lines, and a horizontally scaled run on all but Center); Fewer<tspan>Elements writes the shrunk size.shrunk_area_type_gives_the_size_it_draws_at(vectorcraft-svg,tests/css_rules.rs): checks the CSS rule's font size, letter spacing and line height.tests::shrunk_area_type_is_text_at_the_size_it_draws_at(vectorcraft-cad): checks everyTEXTheight.legacy_ai::tests::shrunk_area_type_is_written_at_the_size_it_draws_at(vectorcraft-eps): checks the sizes, leading and baseline shift read back from the file, and that the read-back type fits its frame.Targeted checks on the final tree:
cargo fmt --all -- --check;cargo clippy -p <crate> --all-targets -- -D warningsandcargo test -p <crate>on vectorcraft-text, vectorcraft-svg, vectorcraft-cad and vectorcraft-eps;cargo xtask brands,layersandassets.On Windows 11 (x86-64) with rustc 1.99.1, on top of
mainat08878722:CRAFT_FONTS_DIR=<craft-fonts checkout> cargo xtask cipasses its 10 steps: 7,608 tests passed, 0 failed, 11 ignored.git merge-treereports no conflicts withmainat08878722or at009384b2; merged with009384b2, which changescrates/text/src/layout.rs, the four new tests pass.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.