Skip to content

Commit a99b8d4

Browse files
committed
Fix monospace
1 parent 6dc8389 commit a99b8d4

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

crates/rnote-engine/src/utils.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,36 @@ pub mod typst {
181181
"sans-serif"
182182
};
183183

184-
tracing::info!("Using math font: {}, text font: {}", math_font, text_font);
184+
// Choose the best available monospace font
185+
let monospace_font = if font_families.contains("JetBrains Mono") {
186+
"JetBrains Mono"
187+
} else if font_families.contains("Noto Sans Mono") {
188+
"Noto Sans Mono"
189+
} else if font_families.contains("DejaVu Sans Mono") {
190+
"DejaVu Sans Mono"
191+
} else if font_families.contains("Liberation Mono") {
192+
"Liberation Mono"
193+
} else if font_families.contains("Courier New") {
194+
"Courier New"
195+
} else if font_families.contains("Consolas") {
196+
"Consolas"
197+
} else if font_families.contains("Monaco") {
198+
"Monaco"
199+
} else {
200+
"monospace"
201+
};
202+
203+
tracing::info!(
204+
"Using math font: {}, text font: {}, monospace font: {}",
205+
math_font,
206+
text_font,
207+
monospace_font
208+
);
185209

186210
// Prepend font configuration to the source
187211
let configured_source = format!(
188-
"#set text(font: \"{}\")\n#show math.equation: set text(font: \"{}\")\n\n{}",
189-
text_font, math_font, source
212+
"#set text(font: \"{}\")\n#show math.equation: set text(font: \"{}\")\n#show raw: set text(font: \"{}\")\n\n{}",
213+
text_font, math_font, monospace_font, source
190214
);
191215

192216
// Create a Typst world (compilation environment)

0 commit comments

Comments
 (0)