From ec5384c97f24c3e6d8284926fd3e415f47fe2b04 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 25 Jul 2021 01:16:38 +0200 Subject: State-based monospace handling --- src/exec/mod.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/exec/mod.rs') diff --git a/src/exec/mod.rs b/src/exec/mod.rs index d61e0793..76857b44 100644 --- a/src/exec/mod.rs +++ b/src/exec/mod.rs @@ -7,7 +7,6 @@ pub use context::*; pub use state::*; use std::fmt::Write; -use std::rc::Rc; use crate::diag::Pass; use crate::eco::EcoString; @@ -75,10 +74,7 @@ impl Exec for RawNode { ctx.parbreak(); } - let snapshot = Rc::clone(&ctx.state.font); - ctx.set_monospace(); - ctx.push_text(&self.text); - ctx.state.font = snapshot; + ctx.push_monospace_text(&self.text); if self.block { ctx.parbreak(); @@ -143,14 +139,9 @@ impl Exec for Value { Value::Str(v) => ctx.push_text(v), Value::Template(v) => v.exec(ctx), Value::Error => {} - other => { - // For values which can't be shown "naturally", we print - // the representation in monospace. - let prev = Rc::clone(&ctx.state.font.families); - ctx.set_monospace(); - ctx.push_text(pretty(other)); - ctx.state.font_mut().families = prev; - } + // For values which can't be shown "naturally", we print the + // representation in monospace. + other => ctx.push_monospace_text(pretty(other)), } } } -- cgit v1.2.3