Skip to content

Commit 510fce1

Browse files
Unblock font loading in rustdoc.css
rustdoc's font loading defaults to "auto", so browsers may block render. But rustdoc's case prefers a faster TTI for scrolling, this means the strictest font-display in use should be "swap". rustdoc's fonts do provide notable legibility improvements but first-time users will have little trouble reading without. This means "optional" is preferred. The one exception is Source Serif Pro: it's a big difference for body text, so "fallback" is preferred over "optional" to cause a (tiny) block.
1 parent 9912925 commit 510fce1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/librustdoc/html/static/rustdoc.css

+9
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
font-family: 'Fira Sans';
44
font-style: normal;
55
font-weight: 400;
6+
font-display: optional;
67
src: local('Fira Sans'), url("FiraSans-Regular.woff") format('woff');
78
}
89
@font-face {
910
font-family: 'Fira Sans';
1011
font-style: normal;
1112
font-weight: 500;
13+
font-display: optional;
1214
src: local('Fira Sans Medium'), url("FiraSans-Medium.woff") format('woff');
1315
}
1416

@@ -17,18 +19,23 @@
1719
font-family: 'Source Serif Pro';
1820
font-style: normal;
1921
font-weight: 400;
22+
/* The difference for body text without this font is greater than other fonts,
23+
* so the 0~100ms block of fallback is preferred over optional, for legibility. */
24+
font-display: fallback;
2025
src: local('Source Serif Pro'), url("SourceSerifPro-Regular.ttf.woff") format('woff');
2126
}
2227
@font-face {
2328
font-family: 'Source Serif Pro';
2429
font-style: italic;
2530
font-weight: 400;
31+
font-display: optional;
2632
src: local('Source Serif Pro Italic'), url("SourceSerifPro-It.ttf.woff") format('woff');
2733
}
2834
@font-face {
2935
font-family: 'Source Serif Pro';
3036
font-style: normal;
3137
font-weight: 700;
38+
font-display: optional;
3239
src: local('Source Serif Pro Bold'), url("SourceSerifPro-Bold.ttf.woff") format('woff');
3340
}
3441

@@ -37,6 +44,7 @@
3744
font-family: 'Source Code Pro';
3845
font-style: normal;
3946
font-weight: 400;
47+
font-display: optional;
4048
/* Avoid using locally installed font because bad versions are in circulation:
4149
* see https://github.com/rust-lang/rust/issues/24355 */
4250
src: url("SourceCodePro-Regular.woff") format('woff');
@@ -45,6 +53,7 @@
4553
font-family: 'Source Code Pro';
4654
font-style: normal;
4755
font-weight: 600;
56+
font-display: optional;
4857
src: url("SourceCodePro-Semibold.woff") format('woff');
4958
}
5059

0 commit comments

Comments
 (0)