summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-11-15 19:55:47 +0100
committerLaurenz <laurmaedje@gmail.com>2019-11-15 19:55:47 +0100
commit0917d89bb899380ba897382b4945c8426f25c66d (patch)
treea9936019abcc7642657e14a828661c21f579dd70 /src/lib.rs
parent9473ae61e9cfc419eb6b48fb0ed15441cc7ad48b (diff)
Generalize flex layouter 🎯
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 21d8b3c0..43f35511 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -17,6 +17,7 @@
pub extern crate toddle;
use std::cell::RefCell;
+use smallvec::smallvec;
use toddle::query::{FontLoader, FontProvider, SharedFontLoader};
use crate::func::Scope;
@@ -93,27 +94,22 @@ impl<'p> Typesetter<'p> {
/// Layout a syntax tree and return the produced layout.
pub fn layout(&self, tree: &SyntaxTree) -> LayoutResult<MultiLayout> {
- let space = LayoutSpace {
- dimensions: self.page_style.dimensions,
- padding: self.page_style.margins,
- };
-
- let pages = layout_tree(
+ Ok(layout_tree(
&tree,
LayoutContext {
loader: &self.loader,
style: &self.text_style,
- space,
- followup_spaces: Some(space),
- shrink_to_fit: false,
+ spaces: smallvec![LayoutSpace {
+ dimensions: self.page_style.dimensions,
+ padding: self.page_style.margins,
+ shrink_to_fit: false,
+ }],
axes: LayoutAxes {
- primary: AlignedAxis::new(Axis::LeftToRight, Alignment::Left).unwrap(),
- secondary: AlignedAxis::new(Axis::TopToBottom, Alignment::Top).unwrap(),
+ primary: AlignedAxis::new(Axis::LeftToRight, Alignment::Origin),
+ secondary: AlignedAxis::new(Axis::TopToBottom, Alignment::Origin),
},
},
- )?;
-
- Ok(pages)
+ )?)
}
/// Process source code directly into a layout.