diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-02-01 13:32:05 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-02-01 13:32:05 +0100 |
| commit | afa344f33db80456bb3091e3863ca673d43c5db8 (patch) | |
| tree | b38b88de8603975dede856878ab598c88c3332fe /library/src/text/raw.rs | |
| parent | c2bd114914513c8ff450b9dcc67aa9b17cf275e1 (diff) | |
Fix raw show rule
Diffstat (limited to 'library/src/text/raw.rs')
| -rw-r--r-- | library/src/text/raw.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index 2f0ec79e..1051992a 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -2,7 +2,9 @@ use once_cell::sync::Lazy; use syntect::highlighting as synt; use typst::syntax::{self, LinkedNode}; -use super::{FontFamily, Hyphenate, LinebreakNode, SmartQuoteNode, TextNode}; +use super::{ + FallbackList, FontFamily, Hyphenate, LinebreakNode, SmartQuoteNode, TextNode, +}; use crate::layout::BlockNode; use crate::prelude::*; @@ -88,7 +90,7 @@ use crate::prelude::*; /// ## Category /// text #[func] -#[capable(Show, Prepare)] +#[capable(Prepare, Show, Finalize)] #[derive(Debug, Hash)] pub struct RawNode { /// The raw text. @@ -203,13 +205,18 @@ impl Show for RawNode { realized = BlockNode(realized).pack(); } + Ok(realized) + } +} + +impl Finalize for RawNode { + fn finalize(&self, realized: Content) -> Content { let mut map = StyleMap::new(); map.set(TextNode::OVERHANG, false); map.set(TextNode::HYPHENATE, Hyphenate(Smart::Custom(false))); map.set(SmartQuoteNode::ENABLED, false); - map.set_family(FontFamily::new("IBM Plex Mono"), styles); - - Ok(realized.styled_with_map(map)) + map.set(TextNode::FAMILY, FallbackList(vec![FontFamily::new("IBM Plex Mono")])); + realized.styled_with_map(map) } } |
