Skip to content

Commit

Permalink
rustdoc: stop preloading Source Serif 4 Bold
Browse files Browse the repository at this point in the history
According to 4198fac, italic fonts are
not preloaded because they're rarely used, but bold fonts are. This
seems to be true of bold Source Code Pro and bold Fira Sans, but
bold and italic Source Serif Pro seem to be equally heavily used.

This is, I assume, the result of using Fira Sans Bold and Source Code
Bold headings, so you only get bold Serif text when the doc author
uses strong `**` emphasis (or within certain kinds of tooltip,
which shouldn't be preloaded because they only show up long after
the page is loaded).

To check this, run these two commands in the browser console to
measure how much they're used. The measurement is extremely rough,
but it gets the idea across: the two styles are about equally popular.

    // count bold elements
    Array.prototype.slice.call(document.querySelectorAll("*")).filter(x => { const y = document.defaultView.getComputedStyle(x); return y.fontFamily.indexOf("Source Serif 4") !== -1 && y.fontWeight > 400 }).length
    // count italic elements
    Array.prototype.slice.call(document.querySelectorAll("*")).filter(x => { const y = document.defaultView.getComputedStyle(x); return y.fontFamily.indexOf("Source Serif 4") !== -1 && y.fontStyle == "italic" }).length

| URL     | Bold | Italic |
|---------|-----:|-------:|
| [std]   |    2 |      9 |
| [Vec]   |    8 |     89 |
| [regex] |   33 |     17 |

[std]: https://doc.rust-lang.org/nightly/std/index.html
[Vec]: https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html
[regex]: https://docs.rs/regex/1.9.5/regex/index.html
  • Loading branch information
notriddle committed Sep 17, 2023
1 parent a09c1f8 commit 2a92981
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/librustdoc/html/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.fira_sans_regular}}"> {# #}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.fira_sans_medium}}"> {# #}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_code_pro_regular}}"> {# #}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_serif_4_bold}}"> {# #}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path|safe}}{{files.source_code_pro_semibold}}"> {# #}
<link rel="stylesheet" {#+ #}
href="{{static_root_path|safe}}{{files.normalize_css}}"> {# #}
Expand Down

0 comments on commit 2a92981

Please sign in to comment.