#Custom default Math font in inside Rust & Library struct

5 messages · Page 1 of 1 (latest)

proven vapor
#

I have implemented typst into my own rust project and created an own world implementation. Everyhting works like a charm. The only problem I face, is that I would like to change the default font type (especially for math).

How can I archive that? The following was my try:

if let Some(Ok(text)) = f.math.scope_mut().get_mut("text") {
  *text = typst::foundations::Value::Str("Poppins".into());
}
bleak crown
#

I'm not sure about a rust solution, but you could always try prepending a set text rule to the start before it gets compiled

proven vapor
#

Yeah, but I would like to make it invisible from the user....

surreal mica
# proven vapor Yeah, but I would like to make it invisible from the user....

You can adjust the Library your World returns and add a new style to its Styles. It would be something like library.styles.set(TextElem::set_font(..)). Or to scope it to math, do something like library.styles.set(Recipe { span: Span::detached(), selector: Some(Selector::Elem(Element::of::<EquationElem>(), None)), transform: Transformation::Style(TextElem::set_font(..).into()) }). (Didn't test the code, so it might have minor errors...)

proven vapor