From c938d58e7058de9631276f31bf526481a360fd77 Mon Sep 17 00:00:00 2001 From: Jubilee <46493976+workingjubilee@users.noreply.github.com> Date: Sun, 24 May 2020 19:05:13 -0700 Subject: [PATCH 1/2] Optional too optional, apparently Local testing did not reveal that "optional" is incredibly eagerly skipped if it involves network transit, so successive page loads didn't actually load the fonts. "fallback" behaved as-predicted (success on next page load). Some styles set to "swap" to guarantee better readability. "Oops." --- src/librustdoc/html/static/rustdoc.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 2cb3347135c1b..6f6fc89acbe68 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -3,12 +3,14 @@ font-family: 'Fira Sans'; font-style: normal; font-weight: 400; + font-display: swap; src: local('Fira Sans'), url("FiraSans-Regular.woff") format('woff'); } @font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 500; + font-display: swap; src: local('Fira Sans Medium'), url("FiraSans-Medium.woff") format('woff'); } @@ -17,18 +19,21 @@ font-family: 'Source Serif Pro'; font-style: normal; font-weight: 400; + font-display: fallback; src: local('Source Serif Pro'), url("SourceSerifPro-Regular.ttf.woff") format('woff'); } @font-face { font-family: 'Source Serif Pro'; font-style: italic; font-weight: 400; + font-display: fallback; src: local('Source Serif Pro Italic'), url("SourceSerifPro-It.ttf.woff") format('woff'); } @font-face { font-family: 'Source Serif Pro'; font-style: normal; font-weight: 700; + font-display: fallback; src: local('Source Serif Pro Bold'), url("SourceSerifPro-Bold.ttf.woff") format('woff'); } @@ -37,6 +42,7 @@ font-family: 'Source Code Pro'; font-style: normal; font-weight: 400; + font-display: fallback; /* Avoid using locally installed font because bad versions are in circulation: * see https://github.com/rust-lang/rust/issues/24355 */ src: url("SourceCodePro-Regular.woff") format('woff'); @@ -45,6 +51,7 @@ font-family: 'Source Code Pro'; font-style: normal; font-weight: 600; + font-display: swap; src: url("SourceCodePro-Semibold.woff") format('woff'); } From 5f9d37ff169a220b97995c04b68b80daa07f7b4f Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Wed, 27 May 2020 17:36:00 -0700 Subject: [PATCH 2/2] 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. --- src/librustdoc/html/static/rustdoc.css | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 6f6fc89acbe68..1687edc36f3a2 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -10,7 +10,7 @@ font-family: 'Fira Sans'; font-style: normal; font-weight: 500; - font-display: swap; + font-display: fallback; src: local('Fira Sans Medium'), url("FiraSans-Medium.woff") format('woff'); } @@ -19,7 +19,9 @@ font-family: 'Source Serif Pro'; font-style: normal; font-weight: 400; - font-display: fallback; + /* This is currently the base font for the entire cascade. It is important + * that it loads in order for rustdoc to look even slightly correct. */ + font-display: swap; src: local('Source Serif Pro'), url("SourceSerifPro-Regular.ttf.woff") format('woff'); } @font-face { @@ -42,7 +44,7 @@ font-family: 'Source Code Pro'; font-style: normal; font-weight: 400; - font-display: fallback; + font-display: swap; /* Avoid using locally installed font because bad versions are in circulation: * see https://github.com/rust-lang/rust/issues/24355 */ src: url("SourceCodePro-Regular.woff") format('woff'); @@ -51,7 +53,7 @@ font-family: 'Source Code Pro'; font-style: normal; font-weight: 600; - font-display: swap; + font-display: fallback; src: url("SourceCodePro-Semibold.woff") format('woff'); }