diff options
| author | Luis David Licea Torres <luislicea@hotmail.com> | 2023-06-12 04:46:34 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-12 12:46:34 +0200 |
| commit | 3284e7fac7c695e42fd2c666befd92742cac96be (patch) | |
| tree | d1467975caef1eabe6af30d0d1b6b3a8b88a9da1 /tests | |
| parent | 93e6638bfe171e3c337876d2143e4e048cd8b279 (diff) | |
Support for inside and outside margins (#1308)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/layout/page-binding.png | bin | 0 -> 17255 bytes | |||
| -rw-r--r-- | tests/src/tests.rs | 6 | ||||
| -rw-r--r-- | tests/typ/layout/page-binding.typ | 46 |
3 files changed, 49 insertions, 3 deletions
diff --git a/tests/ref/layout/page-binding.png b/tests/ref/layout/page-binding.png Binary files differnew file mode 100644 index 00000000..59d73fa4 --- /dev/null +++ b/tests/ref/layout/page-binding.png diff --git a/tests/src/tests.rs b/tests/src/tests.rs index debb3c92..34070e9c 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -24,11 +24,11 @@ use typst::diag::{bail, FileError, FileResult, StrResult}; use typst::doc::{Document, Frame, FrameItem, Meta}; use typst::eval::{func, Datetime, Library, NoneValue, Value}; use typst::font::{Font, FontBook}; -use typst::geom::{Abs, Color, RgbaColor, Sides, Smart}; +use typst::geom::{Abs, Color, RgbaColor, Smart}; use typst::syntax::{Source, SourceId, Span, SyntaxNode}; use typst::util::{Buffer, PathExt}; use typst::World; -use typst_library::layout::PageElem; +use typst_library::layout::{Margin, PageElem}; use typst_library::text::{TextElem, TextSize}; const TYP_DIR: &str = "typ"; @@ -177,7 +177,7 @@ fn library() -> Library { lib.styles .set(PageElem::set_width(Smart::Custom(Abs::pt(120.0).into()))); lib.styles.set(PageElem::set_height(Smart::Auto)); - lib.styles.set(PageElem::set_margin(Sides::splat(Some(Smart::Custom( + lib.styles.set(PageElem::set_margin(Margin::splat(Some(Smart::Custom( Abs::pt(10.0).into(), ))))); lib.styles.set(TextElem::set_size(TextSize(Abs::pt(10.0).into()))); diff --git a/tests/typ/layout/page-binding.typ b/tests/typ/layout/page-binding.typ new file mode 100644 index 00000000..66c8a3c6 --- /dev/null +++ b/tests/typ/layout/page-binding.typ @@ -0,0 +1,46 @@ +// Tests multi-page document with binding. + +--- +#set page(height: 100pt, margin: (inside: 30pt, outside: 20pt)) +#set par(justify: true) +#set text(size: 8pt) + +#page(margin: (x: 20pt), { + set align(center + horizon) + text(20pt, strong[Title]) + v(2em, weak: true) + text(15pt)[Author] +}) + += Introduction +#lorem(35) + +--- +// Test setting the binding explicitly. +#set page(margin: (inside: 30pt)) +#rect(width: 100%)[Bound] +#pagebreak() +#rect(width: 100%)[Left] + +--- +// Test setting the binding explicitly. +#set page(binding: right, margin: (inside: 30pt)) +#rect(width: 100%)[Bound] +#pagebreak() +#rect(width: 100%)[Right] + +--- +// Test setting the binding implicitly. +#set page(margin: (inside: 30pt)) +#set text(lang: "he") +#rect(width: 100%)[Bound] +#pagebreak() +#rect(width: 100%)[Right] + +--- +// Error: 19-44 `inside` and `outside` are mutually exclusive with `left` and `right` +#set page(margin: (left: 1cm, outside: 2cm)) + +--- +// Error: 20-23 must be `left` or `right` +#set page(binding: top) |
