diff options
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/content.rs | 7 | ||||
| -rw-r--r-- | src/eval/styles.rs | 13 | ||||
| -rw-r--r-- | src/eval/value.rs | 8 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/eval/content.rs b/src/eval/content.rs index 5f8c5861..1cdd4bb0 100644 --- a/src/eval/content.rs +++ b/src/eval/content.rs @@ -13,7 +13,7 @@ use crate::diag::StrResult; use crate::library::layout::{FlowChild, FlowNode, PageNode, PlaceNode, Spacing}; use crate::library::prelude::*; use crate::library::structure::{ListItem, ListKind, ListNode, ORDERED, UNORDERED}; -use crate::library::text::{DecoNode, ParChild, ParNode, TextNode, UNDERLINE}; +use crate::library::text::{DecoNode, ParChild, ParNode, UNDERLINE}; use crate::util::EcoString; /// Composable representation of styled content. @@ -133,11 +133,6 @@ impl Content { Self::Styled(Arc::new((self, styles))) } - /// Style this content in monospace. - pub fn monospaced(self) -> Self { - self.styled(TextNode::MONOSPACED, true) - } - /// Underline this content. pub fn underlined(self) -> Self { Self::show(DecoNode::<UNDERLINE>(self)) diff --git a/src/eval/styles.rs b/src/eval/styles.rs index 7fcaf734..a0dc263c 100644 --- a/src/eval/styles.rs +++ b/src/eval/styles.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use super::{Args, Content, Func, Span, Value}; use crate::diag::{At, TypResult}; use crate::library::layout::PageNode; -use crate::library::text::ParNode; +use crate::library::text::{FontFamily, ParNode, TextNode}; use crate::Context; /// A map of style properties. @@ -48,6 +48,17 @@ impl StyleMap { } } + /// Set a font family composed of a preferred family and existing families + /// from a style chain. + pub fn set_family(&mut self, family: FontFamily, existing: StyleChain) { + self.set( + TextNode::FAMILY, + std::iter::once(family) + .chain(existing.get_ref(TextNode::FAMILY).iter().cloned()) + .collect(), + ); + } + /// Set a recipe. pub fn set_recipe(&mut self, node: TypeId, func: Func, span: Span) { self.recipes.push(Recipe { node, func, span }); diff --git a/src/eval/value.rs b/src/eval/value.rs index a76b377d..300444de 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -7,6 +7,7 @@ use std::sync::Arc; use super::{ops, Args, Array, Content, Context, Dict, Func, Layout, StrExt}; use crate::diag::{with_alternative, At, StrResult, TypResult}; use crate::geom::{Angle, Color, Fractional, Length, Linear, Relative, RgbaColor}; +use crate::library::text::RawNode; use crate::syntax::{Span, Spanned}; use crate::util::EcoString; @@ -115,9 +116,10 @@ impl Value { Value::Float(v) => Content::Text(format_eco!("{}", v)), Value::Str(v) => Content::Text(v), Value::Content(v) => v, - // For values which can't be shown "naturally", we print the - // representation in monospace. - v => Content::Text(v.repr()).monospaced(), + + // For values which can't be shown "naturally", we return the raw + // representation. + v => Content::show(RawNode { text: v.repr(), block: false }), } } |
