//! Evaluation state.
use std::rc::Rc;
use fontdock::{fallback, FallbackTree, FontStretch, FontStyle, FontVariant, FontWeight};
use super::Scope;
use crate::geom::{Align, Dir, Gen, Length, Linear, Relative, Sides, Size};
use crate::paper::{Paper, PaperClass, PAPER_A4};
/// The active evaluation state.
#[derive(Debug, Clone, PartialEq)]
pub struct State {
/// The scope that contains function definitions.
pub scope: Scope,
/// The page state.
pub page: PageState,
/// The paragraph state.
pub par: ParState,
/// The font state.
pub font: FontState,
/// The active layouting directions.
pub dirs: Gen
,
/// The active alignments.
pub aligns: Gen,
}
impl Default for State {
fn default() -> Self {
Self {
scope: crate::library::_std(),
page: PageState::default(),
par: ParState::default(),
font: FontState::default(),
dirs: Gen::new(Dir::TTB, Dir::LTR),
aligns: Gen::new(Align::Start, Align::Start),
}
}
}
/// Defines page properties.
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct PageState {
/// The class of this page.
pub class: PaperClass,
/// The width and height of the page.
pub size: Size,
/// The amount of white space in the order [left, top, right, bottom]. If a
/// side is set to `None`, the default for the paper class is used.
pub margins: Sides