Don’t know if it’s a bug in typst or my system or something else, but I can’t set font color when font is set to “Source Code Pro”.
Minimal Working Example
// test.typ:
#set text(fill: color.green)
// This works as expected, a green "lorem ipsum.".
#lorem(2)
// After setting the font to "Source Code Pro",
// all chars become black.
#set text(font: "Source Code Pro")
#lorem(2)
More Info
In my case, other fonts all work fine, ONLY Source Code Pro has this problem.
Putting a SourceCodePro-Regular.otf in the folder, and using command like typst c test.typ --font-path ./ would temporarily solve this problem.
I tried re-installing typst and Source Code Pro and find:
typst c test.typ can still produce test.pdf even with Source Code Pro uninstalled (I make sure that my system has rebooted and other programs can’t find the font Source Code Pro at the moment.)!?!?
typst0.13.1 doesn’t have this problem. 0.14.0~0.14.2 all have this problem.
All color display correctly in tinymist(typst’s language server)'s preview frame.
How could I make Source Code Pro work in typst again?
Thanks in advance!!
I don’t really know how to debug this, but I think it would be helpful if you tell us how (from which source) you installed the non-working font. I know variable fonts aren’t supported by Typst and fonts from Google Fonts are sometimes half broken or only a subset of the features are included.
Maybe your operating system can be helpful.? (I don’t think that should make a difference.)
This is probably due to font fallback. There should be a warning about the missing font but it still compiles, try:
from github release: 0.13.1~0.14.2 (not “installed”, I download and call ./typst.exe directly in the cli)
After uninstalling the font, I tried this line of code, still no warning or error when compiling, and the font in pdf looks just like Source Code Pro (and "Source Code Pro" still appears as an auto-complete option if I type font: " in vscode!?).
Btw, I remember I once clicked Install for All Users (although there’s only 1 user in my computer) when installing the font. When uninstalling it, I just delete the file in C:\Windows\Fonts. Maybe this is an incomplete uninstallation and typst or tinymist could use some kind of “font cache”? (but in Word or PowerPoint I can’t find Source Code Pro)
I tried compiling typst myself and found this “no color for Source Code Pro” problem first appears in commit 96dd67e (“Switch PDF backend to krilla”), I’m not good at coding so … Maybe it has something to do with this commit or krilla?