From e4e79990dad90aea17ea99e54fcd60435927bb56 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 29 Aug 2021 15:09:54 +0200 Subject: Allow body for font function once again --- src/library/layout.rs | 8 ++++---- src/library/mod.rs | 2 +- src/library/text.rs | 12 +++++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/library') diff --git a/src/library/layout.rs b/src/library/layout.rs index 3e8aa7d2..a62be646 100644 --- a/src/library/layout.rs +++ b/src/library/layout.rs @@ -126,17 +126,17 @@ pub fn align(ctx: &mut EvalContext, args: &mut Arguments) -> TypResult { } }; - if let Some(body) = body { + Ok(if let Some(body) = body { let mut template = Template::new(); template.save(); realign(&mut template); template += body; template.restore(); - Ok(Value::Template(template)) + Value::Template(template) } else { realign(&mut ctx.template); - Ok(Value::None) - } + Value::None + }) } /// `box`: Place content in a rectangular box. diff --git a/src/library/mod.rs b/src/library/mod.rs index 9d25a008..a549aa72 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -18,7 +18,7 @@ use std::rc::Rc; use crate::color::{Color, RgbaColor}; use crate::diag::TypResult; -use crate::eval::{Arguments, EvalContext, Scope, Str, Template, Value}; +use crate::eval::{Arguments, EvalContext, Scope, State, Str, Template, Value}; use crate::font::{FontFamily, FontStretch, FontStyle, FontWeight, VerticalFontMetric}; use crate::geom::*; use crate::layout::LayoutNode; diff --git a/src/library/text.rs b/src/library/text.rs index f12794aa..2cb5ccaf 100644 --- a/src/library/text.rs +++ b/src/library/text.rs @@ -20,8 +20,9 @@ pub fn font(ctx: &mut EvalContext, args: &mut Arguments) -> TypResult { let sans_serif = args.named("sans-serif")?; let monospace = args.named("monospace")?; let fallback = args.named("fallback")?; + let body = args.eat::