From c97b3078eb39995528302100d4e8b60c032cadd3 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 25 Jul 2021 12:10:44 +0200 Subject: Merge font and par state into text state --- src/library/layout.rs | 8 ++++---- src/library/text.rs | 48 +++++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 27 deletions(-) (limited to 'src/library') diff --git a/src/library/layout.rs b/src/library/layout.rs index cbc5ff94..ef909bc3 100644 --- a/src/library/layout.rs +++ b/src/library/layout.rs @@ -96,7 +96,7 @@ fn spacing_impl(ctx: &mut EvalContext, args: &mut FuncArgs, axis: GenAxis) -> Va Value::template(move |ctx| { if let Some(linear) = spacing { // TODO: Should this really always be font-size relative? - let amount = linear.resolve(ctx.state.font.size); + let amount = linear.resolve(ctx.state.text.size); ctx.push_spacing(axis, amount); } }) @@ -124,7 +124,7 @@ pub fn align(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { Value::template(move |ctx| { if let Some(horizontal) = horizontal { - ctx.state.aligns.cross = horizontal.to_align(ctx.state.lang.dir); + ctx.state.aligns.cross = horizontal.to_align(ctx.state.dir); } if let Some(vertical) = vertical { @@ -260,7 +260,7 @@ pub fn stack(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { .collect(); ctx.push_into_stack(StackNode { - dirs: Gen::new(ctx.state.lang.dir, dir), + dirs: Gen::new(ctx.state.dir, dir), aspect: None, children, }); @@ -290,7 +290,7 @@ pub fn grid(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { .map(|child| ctx.exec_template_stack(child).into()) .collect(); - let cross_dir = column_dir.unwrap_or(ctx.state.lang.dir); + let cross_dir = column_dir.unwrap_or(ctx.state.dir); let main_dir = row_dir.unwrap_or(cross_dir.axis().other().dir(true)); ctx.push_into_stack(GridNode { diff --git a/src/library/text.rs b/src/library/text.rs index 14a0ee9a..5e3ce204 100644 --- a/src/library/text.rs +++ b/src/library/text.rs @@ -1,6 +1,6 @@ use std::convert::TryFrom; -use crate::exec::{FontState, LineState}; +use crate::exec::{LineState, TextState}; use crate::font::{FontStretch, FontStyle, FontWeight}; use crate::layout::Paint; @@ -28,50 +28,50 @@ pub fn font(ctx: &mut EvalContext, args: &mut FuncArgs) -> Value { let body = args.expect::