summaryrefslogtreecommitdiff
path: root/src/eval/styles.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval/styles.rs')
-rw-r--r--src/eval/styles.rs13
1 files changed, 12 insertions, 1 deletions
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 });