-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax highlighting doesn't work on macOS with Firefox 80 #1304
Comments
mdBook explicitly uses v1.1 of Source Code Pro to avoid this problem. Unfortunately I'm not able to reproduce your problem. Can you provide some more information?
On the affected page, can you check that it is loading the expected font? Right click > Inspect element > Click the "Fonts" tab on the far right. Check that "Fonts used" is "Source Code Pro Medium", and then also expand the "All fonts on page" drop-down, and scroll down to "Source Code Pro" and verify the URL is as expected (something like https://doc.rust-lang.org/book/fonts/source-code-pro-v11-all-charsets-500.woff2). |
Another question: are there any error messages in the console, particularly from highlightjs? |
I do not see any JS errors, only these:
|
Those errors were for https://doc.rust-lang.org/book/ch01-02-hello-world.html. I've been having this issue with the Rust book, Rust by Example, and even the mdBook User Guide, so I thought that this was an issue with mdBook and not one of those. Also, as I mentioned before, I am not having this issue with the Rust docs (e.g., https://doc.rust-lang.org/std). |
|
Also, the issue is resolved when I remove "Source Code Pro" from the CSS src: local("Source Code Pro Medium"), local("SourceCodePro-Medium"), url("source-code-pro-v11-all-charsets-500.woff2") format("woff2"); |
So I had the same issue I think, but I noticed it started happening right after I updated my macbook to 10.15.6 (19G2021). When I would change the font to anything invalid in the style editor, it would start syntax highlighting. Hmm. So I checkout out my fonts in font book in OSX. Source Code Pro had two versions installed, and one was disabled. Very strange. Removed the whole font family, now the syntax highlighting is back. Not really sure what that's about, but I think this is an OSX issue. |
For me, this issue only started happening when I updated to Firefox 80 from 79; it was working fine for me before. |
I may be mistaken, but I have a feeling that this line is the problem: mdBook/src/theme/fonts/fonts.css Lines 99 to 100 in f6768b8
It seems to prefer local versions of Source Code Pro over the bundled version. |
Putting the bundled font first in the list fixes the issue. |
Why would the local font not work? It seems to make sense that if you have the font installed locally, it should choose to use that one first, otherwise it will basically never get used. |
@flapjackfritz See rust-lang/rust#24355 and https://bugzilla.mozilla.org/show_bug.cgi?id=1520157 for more information about this issue. Basically, some versions of the font are buggy and in some situations don't handle colors appropriately. For some reason, in Firefox 80, this issue emerged for more people on macOS. Everything worked fine for me before, but as soon as I updated from 79 to 80, syntax highlighting didn't work on sites like https://play.rust-lang.org (see here for information about that in particular). Also, all mdBooks (for example, https://doc.rust-lang.org/book) no longer have working syntax highlighting for me. Some versions of Source Code Pro do not have this issue, though, which is why Rustdoc and mdBook bundle their own versions that don't have this issue. Rustdoc does not even try to use a local version, whereas mdBook prefers a local version. So I think it would be better to prefer the bundled version, as Rustdoc does, which is known to not have this issue, rather than relying on a user's local font, which may or may not have the issue. |
Drop the last user of Google Fonts by including SourceCodePro in the template. We don't fall back to the installed copy of SourceCodePro because there have been multiple instances of bad versions being distributed over the years. See, for instance: - rust-lang/rust#24355 - rust-lang/mdBook#1304
Most likely because of this issue with Firefox (also see https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Firefox.2080.2E0.20removes.20colors.20from.20the.20playground.20on.20MacOS.20.2E.2E.2E).
However, this issue does not occur with Rustdoc. According to @ehuss, this is because:
Perhaps mdBook can use the same trick as Rustdoc to avoid this issue?
The text was updated successfully, but these errors were encountered: