Skip to content

Commit 5f9d37f

Browse files
Use swap for base fonts in a font family
Font-display options allow a CSS author to opt in to faster loading, in exchange for less control over the display. Font-families will fall back to a "nearby" (in weight/style) font. It is important that some of the base fonts, like Source Serif Pro, load correctly. Swap should be preferred for them.
1 parent c938d58 commit 5f9d37f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/librustdoc/html/static/rustdoc.css

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
font-family: 'Fira Sans';
1111
font-style: normal;
1212
font-weight: 500;
13-
font-display: swap;
13+
font-display: fallback;
1414
src: local('Fira Sans Medium'), url("FiraSans-Medium.woff") format('woff');
1515
}
1616

@@ -19,7 +19,9 @@
1919
font-family: 'Source Serif Pro';
2020
font-style: normal;
2121
font-weight: 400;
22-
font-display: fallback;
22+
/* This is currently the base font for the entire cascade. It is important
23+
* that it loads in order for rustdoc to look even slightly correct. */
24+
font-display: swap;
2325
src: local('Source Serif Pro'), url("SourceSerifPro-Regular.ttf.woff") format('woff');
2426
}
2527
@font-face {
@@ -42,7 +44,7 @@
4244
font-family: 'Source Code Pro';
4345
font-style: normal;
4446
font-weight: 400;
45-
font-display: fallback;
47+
font-display: swap;
4648
/* Avoid using locally installed font because bad versions are in circulation:
4749
* see https://github.com/rust-lang/rust/issues/24355 */
4850
src: url("SourceCodePro-Regular.woff") format('woff');
@@ -51,7 +53,7 @@
5153
font-family: 'Source Code Pro';
5254
font-style: normal;
5355
font-weight: 600;
54-
font-display: swap;
56+
font-display: fallback;
5557
src: url("SourceCodePro-Semibold.woff") format('woff');
5658
}
5759

0 commit comments

Comments
 (0)