Rollup merge of #82545 - jsha:woff2, r=GuillaumeGomez

rustdoc: add optional woff2 versions of FiraSans.

For browsers that support woff2 (most modern ones:
https://caniuse.com/woff2), this offers a reduction in download size
for these two fonts from 362k to 257k (32% reduction). It decreases the
total page size for `struct.String.html` (counting all subresources) by
about 2.5%.

If this is interesting, I'm happy to apply the same treatment to the
other fonts, but these two are the biggest.
This commit is contained in:
Guillaume Gomez 2021-02-26 15:52:36 +01:00 committed by GitHub
commit b4ded5a07b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 2 deletions

View File

@ -883,6 +883,8 @@ themePicker.onblur = handleThemeButtonsBlur;
static_files::NORMALIZE_CSS,
options.enable_minification,
)?;
write(cx.dst.join("FiraSans-Regular.woff2"), static_files::fira_sans::REGULAR2)?;
write(cx.dst.join("FiraSans-Medium.woff2"), static_files::fira_sans::MEDIUM2)?;
write(cx.dst.join("FiraSans-Regular.woff"), static_files::fira_sans::REGULAR)?;
write(cx.dst.join("FiraSans-Medium.woff"), static_files::fira_sans::MEDIUM)?;
write(cx.dst.join("FiraSans-LICENSE.txt"), static_files::fira_sans::LICENSE)?;

Binary file not shown.

Binary file not shown.

View File

@ -3,13 +3,17 @@
font-family: 'Fira Sans';
font-style: normal;
font-weight: 400;
src: local('Fira Sans'), url("FiraSans-Regular.woff") format('woff');
src: local('Fira Sans'),
url("FiraSans-Regular.woff2") format("woff2"),
url("FiraSans-Regular.woff") format('woff');
}
@font-face {
font-family: 'Fira Sans';
font-style: normal;
font-weight: 500;
src: local('Fira Sans Medium'), url("FiraSans-Medium.woff") format('woff');
src: local('Fira Sans Medium'),
url("FiraSans-Medium.woff2") format("woff2"),
url("FiraSans-Medium.woff") format('woff');
}
/* See SourceSerifPro-LICENSE.txt for the Source Serif Pro license. */

View File

@ -76,9 +76,15 @@ crate mod fira_sans {
/// The file `FiraSans-Regular.woff`, the Regular variant of the Fira Sans font.
crate static REGULAR: &[u8] = include_bytes!("static/FiraSans-Regular.woff");
/// The file `FiraSans-Regular.woff2`, the Regular variant of the Fira Sans font in woff2.
crate static REGULAR2: &[u8] = include_bytes!("static/FiraSans-Regular.woff2");
/// The file `FiraSans-Medium.woff`, the Medium variant of the Fira Sans font.
crate static MEDIUM: &[u8] = include_bytes!("static/FiraSans-Medium.woff");
/// The file `FiraSans-Medium.woff2`, the Medium variant of the Fira Sans font in woff2.
crate static MEDIUM2: &[u8] = include_bytes!("static/FiraSans-Medium.woff2");
/// The file `FiraSans-LICENSE.txt`, the license text for the Fira Sans font.
crate static LICENSE: &[u8] = include_bytes!("static/FiraSans-LICENSE.txt");
}