diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index 2f0ec79ec..1051992a1 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) } } diff --git a/tests/ref/text/raw.png b/tests/ref/text/raw.png index f7912051d..e2fd87d0a 100644 Binary files a/tests/ref/text/raw.png and b/tests/ref/text/raw.png differ diff --git a/tests/typ/math/syntax.typ b/tests/typ/math/syntax.typ index 80facfb23..8ffded298 100644 --- a/tests/typ/math/syntax.typ +++ b/tests/typ/math/syntax.typ @@ -1,11 +1,10 @@ #set page(width: auto) -#set text("Latin Modern Roman") #show : it => table( columns: 2, inset: 8pt, ..it.text .split("\n") - .map(line => (text(10pt, raw(line, lang: "typ")), eval(line) + [ ])) + .map(line => (raw(line, lang: "typ"), text("Latin Modern Roman", eval(line)))) .flatten() ) diff --git a/tests/typ/text/raw.typ b/tests/typ/text/raw.typ index 96a23b66d..f8731cca5 100644 --- a/tests/typ/text/raw.typ +++ b/tests/typ/text/raw.typ @@ -44,6 +44,11 @@ The keyword ```rust let```. C ``` +--- +// Text show rule +#show raw: set text("Roboto") +`Roboto` + --- // Unterminated. // Error: 2:1 expected 1 backtick