-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
HTML Documentation doesn't load locally-saved fonts in macOS Safari #98769
Comments
Thanks for the report! That's strange - I could imagine reasons why Safari might refuse to load fonts, but I can't think of why it would affect both woff and woff2. Since I don't have a Safari handy at the moment, could you do me a favor - check what happens if you remove the |
To clarify: woff files work just fine (even in combination with woff2 files), but they aren't shipped with rustdoc anymore. Indeed, removing the |
Thanks for testing that! That confirms my suspicion: the problem isn't woff vs woff2, but that the But I'm guessing on Safari something different is happening: the first fetch "poisons" the URL as you say, so even once the CSS is loaded, Safari's attempt to load that font URL fails. This worked when there was also a .woff file in the CSS, because the .woff file wasn't preloaded and so wasn't poisoned. I think this is a bug in Safari and it would be good to file it and get it fixed. Working around the bug in rustdoc could mean putting a small block of inline JS in the |
WebKit issue: https://bugs.webkit.org/show_bug.cgi?id=249887 |
Clarifying question: according to #85444 I would expect the Safari experience to be even worse than this, with no CSS loaded it all. Do you perhaps have the Develop menu enabled? |
I have the Develop menu enabled. @kadiwa4 do you? |
@jsha @notriddle Yes, I have it enabled |
…d, r=notriddle rustdoc: do not preload fonts when browsing locally First PR, please let me know if I'm doing anything wrong. As noted in rust-lang#98769, currently `cargo doc --open` on macOS/Safari (17.2.1) doesn't load fonts due to a CORS issue. (webkit issue [here](https://bugs.webkit.org/show_bug.cgi?id=249887)). This patch moves the font preloads inside a js if statement as suggested in the GitHub issue. I tried something more elegant with iterating over a tera array of fonts, but ran into issues, so here's the dumb fix. Only thing to note is that the font path is interpolated into a template string, so HTML escaping works fine, but it will break if there's a backtick or `${` in the font path. Not sure if this is a big deal.
Rollup merge of rust-lang#122410 - rjeli:rustdoc-no-local-font-preload, r=notriddle rustdoc: do not preload fonts when browsing locally First PR, please let me know if I'm doing anything wrong. As noted in rust-lang#98769, currently `cargo doc --open` on macOS/Safari (17.2.1) doesn't load fonts due to a CORS issue. (webkit issue [here](https://bugs.webkit.org/show_bug.cgi?id=249887)). This patch moves the font preloads inside a js if statement as suggested in the GitHub issue. I tried something more elegant with iterating over a tera array of fonts, but ran into issues, so here's the dumb fix. Only thing to note is that the font path is interpolated into a template string, so HTML escaping works fine, but it will break if there's a backtick or `${` in the font path. Not sure if this is a big deal.
When viewing locally-saved documentation (
file:///
), rustdoc's output website isn't able to load in any of the woff2 fonts. Since #96279 removed the woff versions of the fonts, the browser defaults to other fonts, and it turns out Times and Menlo don't look great in combination.Update: since #115904 (1.75.0), the bold version of Source Serif 4 is now used.
Version: macOS 12.4 / Safari 15.5 (still an issue in 17.2.1)
Rust/Rustdoc version: 1.62.0, works fine on 1.61.0
Workaround script: https://gist.github.com/kadiwa4/8e81b820217fdb8d1fb70e2108d1a58d
Web console:
The text was updated successfully, but these errors were encountered: