diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-11-18 15:10:11 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-11-18 15:10:11 +0100 |
| commit | 1a6fb48bc5e95d0a9ef243ab62517557189c0eea (patch) | |
| tree | 06f704fe638d5ae25f4976874500c5da75316348 /src/layout/mod.rs | |
| parent | 1eb25f86dd6763c4f2d7e60b6d09af60ada50af6 (diff) | |
Page style modification functions 📜
- `page.size`
- `page.margins`
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index a4514704..426a51ec 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -9,7 +9,7 @@ use toddle::Error as FontError; use crate::func::Command; use crate::size::{Size, Size2D, SizeBox}; -use crate::style::TextStyle; +use crate::style::{PageStyle, TextStyle}; use crate::syntax::{FuncCall, Node, SyntaxTree}; mod actions; @@ -131,9 +131,15 @@ pub struct LayoutContext<'a, 'p> { /// using [`layout_text`]. pub loader: &'a SharedFontLoader<'p>, + /// Whether this layouting process handles the top-level pages. + pub top_level: bool, + /// The style to set text with. This includes sizes and font classes /// which determine which font from the loaders selection is used. - pub style: &'a TextStyle, + pub text_style: &'a TextStyle, + + /// The current size and margins of the top-level pages. + pub page_style: PageStyle, /// The spaces to layout in. pub spaces: LayoutSpaces, @@ -281,6 +287,8 @@ pub enum Alignment { /// The error type for layouting. pub enum LayoutError { + /// An action is unallowed in the active context. + Unallowed(&'static str), /// There is not enough space to add an item. NotEnoughSpace(&'static str), /// There was no suitable font for the given character. @@ -295,6 +303,7 @@ pub type LayoutResult<T> = Result<T, LayoutError>; error_type! { err: LayoutError, show: f => match err { + LayoutError::Unallowed(desc) => write!(f, "unallowed: {}", desc), LayoutError::NotEnoughSpace(desc) => write!(f, "not enough space: {}", desc), LayoutError::NoSuitableFont(c) => write!(f, "no suitable font for '{}'", c), LayoutError::Font(err) => write!(f, "font error: {}", err), |
