Can I change font size depending on what font is used?

I have set my raw font to JetBrains Mono, but added the built in font DejaVu Sans Mono as a fallback, so that on systems where it isn’t installed, raw text still looks okay-ish. Now the problem is since DejaVu is the “larger” font, this breaks some layouting in my documents. Can I adjust the font size based on which font has been used?

#show raw: set text(font: ("JetBrains Mono", "DejaVu Sans Mono") size: 1em)

If at all possible, I’d like it to work with lists and strings, since typstyle likes to turn single-element lists into “regular” items.

You can’t. Size per font · Issue #6295 · typst/typst · GitHub

A workaround is to use regex with special character set or Unicode property/script category syntax, like in Size per font · Issue #6295 · typst/typst · GitHub.

1 Like