diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-03-11 10:48:29 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-03-11 10:48:29 +0100 |
| commit | c1b1dbcc0925ba1730fabbfbca3c8b99831c5561 (patch) | |
| tree | 6e4cb30753729c699bd899a7f2ec352e276beee8 /tests | |
| parent | 4e5f85aa4ac0d6b51323bb2a6e1fbd3f4f46babb (diff) | |
Better expansion behaviour 🐪
This makes expansion behaviour inheritable by placing it into the area and passing it down during layouting instead of computing some approximation of what we want during execution.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/expand.png | bin | 0 -> 1419 bytes | |||
| -rw-r--r-- | tests/typ/expand.typ | 14 | ||||
| -rw-r--r-- | tests/typeset.rs | 5 |
3 files changed, 16 insertions, 3 deletions
diff --git a/tests/ref/expand.png b/tests/ref/expand.png Binary files differnew file mode 100644 index 00000000..fc1f5de9 --- /dev/null +++ b/tests/ref/expand.png diff --git a/tests/typ/expand.typ b/tests/typ/expand.typ new file mode 100644 index 00000000..3b242928 --- /dev/null +++ b/tests/typ/expand.typ @@ -0,0 +1,14 @@ +// Test fit/fill expansion. + +--- +#let right(body) = align(right, body) +#let pad(body) = pad(left: 10pt, right: 10pt, body) + +// Top-level paragraph fills page, boxed paragraph only when width is fixed. +L #right[R] \ +#box(width: 50pt)[L #right[R]] \ +#box[L #right[R]] \ + +// Pad inherits expansion behaviour. +#pad[PL #right[PR]] \ +#box(pad[PL #right[PR]]) diff --git a/tests/typeset.rs b/tests/typeset.rs index 232dfa5c..ff0e44bc 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -20,8 +20,8 @@ use typst::eval::{EvalContext, Scope, Value, ValueArgs, ValueFunc}; use typst::exec::State; use typst::export::pdf; use typst::font::FsIndexExt; -use typst::geom::{Length, Point, Sides, Size, Spec}; -use typst::layout::{Element, Expansion, Fill, Frame, Geometry, Image, Shape}; +use typst::geom::{Length, Point, Sides, Size}; +use typst::layout::{Element, Fill, Frame, Geometry, Image, Shape}; use typst::library; use typst::parse::{LineMap, Scanner}; use typst::shaping::Shaped; @@ -202,7 +202,6 @@ fn test_part( // large and fit them to match their content. let mut state = State::default(); state.page.size = Size::new(Length::pt(120.0), Length::raw(f64::INFINITY)); - state.page.expand = Spec::new(Expansion::Fill, Expansion::Fit); state.page.margins = Sides::uniform(Some(Length::pt(10.0).into())); let Pass { output: mut frames, diags } = typeset(env, &src, &scope, state); |
