Skip to content

Commit

Permalink
Rollup merge of #96279 - GuillaumeGomez:remove-woff-fonts, r=camelid,…
Browse files Browse the repository at this point in the history
…jsha

rustdoc: Remove .woff font files

Copying `@jsha's` great comment:

> Right now we ship 1.5MB of woff files in the rustdoc binary, and 1MB of woff2 files, for a total of 2.5MB.
>
> Per:
>
> https://caniuse.com/woff
> https://caniuse.com/woff2
>
> The only listed browser that supports woff and not woff2 is IE, which is not supported per https://github.com/rust-lang/rfcs/blob/master/text/1985-tiered-browser-support.md.
>
> I propose we stop shipping woff files and save 1.5MB from the rustdoc binary (and from each doc build).

r? `@jsha`
  • Loading branch information
Dylan-DPC authored Apr 25, 2022
2 parents 93db30a + 5c1965a commit 2381897
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 88 deletions.
27 changes: 9 additions & 18 deletions src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,18 @@ use crate::{try_err, try_none};

static FILES_UNVERSIONED: Lazy<FxHashMap<&str, &[u8]>> = Lazy::new(|| {
map! {
"FiraSans-Regular.woff2" => static_files::fira_sans::REGULAR2,
"FiraSans-Medium.woff2" => static_files::fira_sans::MEDIUM2,
"FiraSans-Regular.woff" => static_files::fira_sans::REGULAR,
"FiraSans-Medium.woff" => static_files::fira_sans::MEDIUM,
"FiraSans-Regular.woff2" => static_files::fira_sans::REGULAR,
"FiraSans-Medium.woff2" => static_files::fira_sans::MEDIUM,
"FiraSans-LICENSE.txt" => static_files::fira_sans::LICENSE,
"SourceSerif4-Regular.ttf.woff2" => static_files::source_serif_4::REGULAR2,
"SourceSerif4-Bold.ttf.woff2" => static_files::source_serif_4::BOLD2,
"SourceSerif4-It.ttf.woff2" => static_files::source_serif_4::ITALIC2,
"SourceSerif4-Regular.ttf.woff" => static_files::source_serif_4::REGULAR,
"SourceSerif4-Bold.ttf.woff" => static_files::source_serif_4::BOLD,
"SourceSerif4-It.ttf.woff" => static_files::source_serif_4::ITALIC,
"SourceSerif4-Regular.ttf.woff2" => static_files::source_serif_4::REGULAR,
"SourceSerif4-Bold.ttf.woff2" => static_files::source_serif_4::BOLD,
"SourceSerif4-It.ttf.woff2" => static_files::source_serif_4::ITALIC,
"SourceSerif4-LICENSE.md" => static_files::source_serif_4::LICENSE,
"SourceCodePro-Regular.ttf.woff2" => static_files::source_code_pro::REGULAR2,
"SourceCodePro-Semibold.ttf.woff2" => static_files::source_code_pro::SEMIBOLD2,
"SourceCodePro-It.ttf.woff2" => static_files::source_code_pro::ITALIC2,
"SourceCodePro-Regular.ttf.woff" => static_files::source_code_pro::REGULAR,
"SourceCodePro-Semibold.ttf.woff" => static_files::source_code_pro::SEMIBOLD,
"SourceCodePro-It.ttf.woff" => static_files::source_code_pro::ITALIC,
"SourceCodePro-Regular.ttf.woff2" => static_files::source_code_pro::REGULAR,
"SourceCodePro-Semibold.ttf.woff2" => static_files::source_code_pro::SEMIBOLD,
"SourceCodePro-It.ttf.woff2" => static_files::source_code_pro::ITALIC,
"SourceCodePro-LICENSE.txt" => static_files::source_code_pro::LICENSE,
"NanumBarunGothic.ttf.woff2" => static_files::nanum_barun_gothic::REGULAR2,
"NanumBarunGothic.ttf.woff" => static_files::nanum_barun_gothic::REGULAR,
"NanumBarunGothic.ttf.woff2" => static_files::nanum_barun_gothic::REGULAR,
"NanumBarunGothic-LICENSE.txt" => static_files::nanum_barun_gothic::LICENSE,
"LICENSE-MIT.txt" => static_files::LICENSE_MIT,
"LICENSE-APACHE.txt" => static_files::LICENSE_APACHE,
Expand Down
10 changes: 3 additions & 7 deletions src/librustdoc/html/static/COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ These documentation pages include resources by third parties. This copyright
file applies only to those resources. The following third party resources are
included, and carry their own copyright notices and license terms:

* Fira Sans (FiraSans-Regular.woff2, FiraSans-Medium.woff2,
FiraSans-Regular.woff, FiraSans-Medium.woff):
* Fira Sans (FiraSans-Regular.woff2, FiraSans-Medium.woff2):

Copyright (c) 2014, Mozilla Foundation https://mozilla.org/
with Reserved Font Name Fira Sans.
Expand All @@ -25,9 +24,7 @@ included, and carry their own copyright notices and license terms:
Licensed under the MIT license (see LICENSE-MIT.txt).

* Source Code Pro (SourceCodePro-Regular.ttf.woff2,
SourceCodePro-Semibold.ttf.woff2, SourceCodePro-It.ttf.woff2,
SourceCodePro-Regular.ttf.woff, SourceCodePro-Semibold.ttf.woff,
SourceCodePro-It.ttf.woff):
SourceCodePro-Semibold.ttf.woff2, SourceCodePro-It.ttf.woff2):

Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark
Expand All @@ -37,8 +34,7 @@ included, and carry their own copyright notices and license terms:
See SourceCodePro-LICENSE.txt.

* Source Serif 4 (SourceSerif4-Regular.ttf.woff2, SourceSerif4-Bold.ttf.woff2,
SourceSerif4-It.ttf.woff2, SourceSerif4-Regular.ttf.woff,
SourceSerif4-Bold.ttf.woff, SourceSerif4-It.ttf.woff):
SourceSerif4-It.ttf.woff2):

Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name
'Source'. All Rights Reserved. Source is a trademark of Adobe in the United
Expand Down
27 changes: 9 additions & 18 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
font-style: normal;
font-weight: 400;
src: local('Fira Sans'),
url("FiraSans-Regular.woff2") format("woff2"),
url("FiraSans-Regular.woff") format('woff');
url("FiraSans-Regular.woff2") format("woff2");
font-display: swap;
}
@font-face {
font-family: 'Fira Sans';
font-style: normal;
font-weight: 500;
src: local('Fira Sans Medium'),
url("FiraSans-Medium.woff2") format("woff2"),
url("FiraSans-Medium.woff") format('woff');
url("FiraSans-Medium.woff2") format("woff2");
font-display: swap;
}

Expand All @@ -24,26 +22,23 @@
font-style: normal;
font-weight: 400;
src: local('Source Serif 4'),
url("SourceSerif4-Regular.ttf.woff2") format("woff2"),
url("SourceSerif4-Regular.ttf.woff") format("woff");
url("SourceSerif4-Regular.ttf.woff2") format("woff2");
font-display: swap;
}
@font-face {
font-family: 'Source Serif 4';
font-style: italic;
font-weight: 400;
src: local('Source Serif 4 Italic'),
url("SourceSerif4-It.ttf.woff2") format("woff2"),
url("SourceSerif4-It.ttf.woff") format("woff");
url("SourceSerif4-It.ttf.woff2") format("woff2");
font-display: swap;
}
@font-face {
font-family: 'Source Serif 4';
font-style: normal;
font-weight: 700;
src: local('Source Serif 4 Bold'),
url("SourceSerif4-Bold.ttf.woff2") format("woff2"),
url("SourceSerif4-Bold.ttf.woff") format("woff");
url("SourceSerif4-Bold.ttf.woff2") format("woff2");
font-display: swap;
}

Expand All @@ -54,32 +49,28 @@
font-weight: 400;
/* Avoid using locally installed font because bad versions are in circulation:
* see https://github.com/rust-lang/rust/issues/24355 */
src: url("SourceCodePro-Regular.ttf.woff2") format("woff2"),
url("SourceCodePro-Regular.ttf.woff") format("woff");
src: url("SourceCodePro-Regular.ttf.woff2") format("woff2");
font-display: swap;
}
@font-face {
font-family: 'Source Code Pro';
font-style: italic;
font-weight: 400;
src: url("SourceCodePro-It.ttf.woff2") format("woff2"),
url("SourceCodePro-It.ttf.woff") format("woff");
src: url("SourceCodePro-It.ttf.woff2") format("woff2");
font-display: swap;
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 600;
src: url("SourceCodePro-Semibold.ttf.woff2") format("woff2"),
url("SourceCodePro-Semibold.ttf.woff") format("woff");
src: url("SourceCodePro-Semibold.ttf.woff2") format("woff2");
font-display: swap;
}

/* Avoid using legacy CJK serif fonts in Windows like Batang. */
@font-face {
font-family: 'NanumBarunGothic';
src: url("NanumBarunGothic.ttf.woff2") format("woff2"),
url("NanumBarunGothic.ttf.woff") format("woff");
src: url("NanumBarunGothic.ttf.woff2") format("woff2");
font-display: swap;
unicode-range: U+AC00-D7AF, U+1100-11FF, U+3130-318F, U+A960-A97F, U+D7B0-D7FF;
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
51 changes: 9 additions & 42 deletions src/librustdoc/html/static_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,72 +92,47 @@ crate mod themes {

/// Files related to the Fira Sans font.
crate mod fira_sans {
/// The file `FiraSans-Regular.woff`, the Regular variant of the Fira Sans font.
crate static REGULAR: &[u8] = include_bytes!("static/fonts/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/fonts/FiraSans-Regular.woff2");

/// The file `FiraSans-Medium.woff`, the Medium variant of the Fira Sans font.
crate static MEDIUM: &[u8] = include_bytes!("static/fonts/FiraSans-Medium.woff");
crate static REGULAR: &[u8] = include_bytes!("static/fonts/FiraSans-Regular.woff2");

/// The file `FiraSans-Medium.woff2`, the Medium variant of the Fira Sans font in woff2.
crate static MEDIUM2: &[u8] = include_bytes!("static/fonts/FiraSans-Medium.woff2");
crate static MEDIUM: &[u8] = include_bytes!("static/fonts/FiraSans-Medium.woff2");

/// The file `FiraSans-LICENSE.txt`, the license text for the Fira Sans font.
crate static LICENSE: &[u8] = include_bytes!("static/fonts/FiraSans-LICENSE.txt");
}

/// Files related to the Source Serif 4 font.
crate mod source_serif_4 {
/// The file `SourceSerif4-Regular.ttf.woff`, the Regular variant of the Source Serif 4 font.
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceSerif4-Regular.ttf.woff");

/// The file `SourceSerif4-Regular.ttf.woff2`, the Regular variant of the Source Serif 4 font in
/// woff2.
crate static REGULAR2: &[u8] = include_bytes!("static/fonts/SourceSerif4-Regular.ttf.woff2");

/// The file `SourceSerif4-Bold.ttf.woff`, the Bold variant of the Source Serif 4 font.
crate static BOLD: &[u8] = include_bytes!("static/fonts/SourceSerif4-Bold.ttf.woff");
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceSerif4-Regular.ttf.woff2");

/// The file `SourceSerif4-Bold.ttf.woff2`, the Bold variant of the Source Serif 4 font in
/// woff2.
crate static BOLD2: &[u8] = include_bytes!("static/fonts/SourceSerif4-Bold.ttf.woff2");

/// The file `SourceSerif4-It.ttf.woff`, the Italic variant of the Source Serif 4 font.
crate static ITALIC: &[u8] = include_bytes!("static/fonts/SourceSerif4-It.ttf.woff");
crate static BOLD: &[u8] = include_bytes!("static/fonts/SourceSerif4-Bold.ttf.woff2");

/// The file `SourceSerif4-It.ttf.woff2`, the Italic variant of the Source Serif 4 font in
/// woff2.
crate static ITALIC2: &[u8] = include_bytes!("static/fonts/SourceSerif4-It.ttf.woff2");
crate static ITALIC: &[u8] = include_bytes!("static/fonts/SourceSerif4-It.ttf.woff2");

/// The file `SourceSerif4-LICENSE.txt`, the license text for the Source Serif 4 font.
crate static LICENSE: &[u8] = include_bytes!("static/fonts/SourceSerif4-LICENSE.md");
}

/// Files related to the Source Code Pro font.
crate mod source_code_pro {
/// The file `SourceCodePro-Regular.ttf.woff`, the Regular variant of the Source Code Pro font.
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceCodePro-Regular.ttf.woff");

/// The file `SourceCodePro-Regular.ttf.woff2`, the Regular variant of the Source Code Pro font
/// in woff2.
crate static REGULAR2: &[u8] = include_bytes!("static/fonts/SourceCodePro-Regular.ttf.woff2");

/// The file `SourceCodePro-Semibold.ttf.woff`, the Semibold variant of the Source Code Pro
/// font.
crate static SEMIBOLD: &[u8] = include_bytes!("static/fonts/SourceCodePro-Semibold.ttf.woff");
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceCodePro-Regular.ttf.woff2");

/// The file `SourceCodePro-Semibold.ttf.woff2`, the Semibold variant of the Source Code Pro
/// font in woff2.
crate static SEMIBOLD2: &[u8] = include_bytes!("static/fonts/SourceCodePro-Semibold.ttf.woff2");

/// The file `SourceCodePro-It.ttf.woff`, the Italic variant of the Source Code Pro font.
crate static ITALIC: &[u8] = include_bytes!("static/fonts/SourceCodePro-It.ttf.woff");
crate static SEMIBOLD: &[u8] = include_bytes!("static/fonts/SourceCodePro-Semibold.ttf.woff2");

/// The file `SourceCodePro-It.ttf.woff2`, the Italic variant of the Source Code Pro font in
/// woff2.
crate static ITALIC2: &[u8] = include_bytes!("static/fonts/SourceCodePro-It.ttf.woff2");
crate static ITALIC: &[u8] = include_bytes!("static/fonts/SourceCodePro-It.ttf.woff2");

/// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font.
crate static LICENSE: &[u8] = include_bytes!("static/fonts/SourceCodePro-LICENSE.txt");
Expand All @@ -176,19 +151,11 @@ crate mod source_code_pro {
/// ```sh
/// pyftsubset NanumBarunGothic.ttf \
/// --unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
/// --output-file=NanumBarunGothic.ttf.woff --flavor=woff
/// ```
/// ```sh
/// pyftsubset NanumBarunGothic.ttf \
/// --unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
/// --output-file=NanumBarunGothic.ttf.woff2 --flavor=woff2
/// ```
crate mod nanum_barun_gothic {
/// The file `NanumBarunGothic.ttf.woff`, the Regular variant of the Nanum Barun Gothic font.
crate static REGULAR: &[u8] = include_bytes!("static/fonts/NanumBarunGothic.ttf.woff");

/// The file `NanumBarunGothic.ttf.woff2`, the Regular variant of the Nanum Barun Gothic font.
crate static REGULAR2: &[u8] = include_bytes!("static/fonts/NanumBarunGothic.ttf.woff2");
crate static REGULAR: &[u8] = include_bytes!("static/fonts/NanumBarunGothic.ttf.woff2");

/// The file `NanumBarunGothic-LICENSE.txt`, the license text of the Nanum Barun Gothic font.
crate static LICENSE: &[u8] = include_bytes!("static/fonts/NanumBarunGothic-LICENSE.txt");
Expand Down
6 changes: 3 additions & 3 deletions src/test/run-make/emit-shared-files/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ invocation-only:
[ -e $(INVOCATION_ONLY)/x/index.html ]
[ -e $(INVOCATION_ONLY)/theme-xxx.css ] # generated from z.css
! [ -e $(INVOCATION_ONLY)/storage-xxx.js ]
! [ -e $(INVOCATION_ONLY)/SourceSerif4-It.ttf.woff ]
! [ -e $(INVOCATION_ONLY)/SourceSerif4-It.ttf.woff2 ]

# FIXME: this probably shouldn't have a suffix
[ -e $(INVOCATION_ONLY)/y-xxx.css ]
Expand All @@ -24,7 +24,7 @@ invocation-only:
toolchain-only:
$(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources --output $(TOOLCHAIN_ONLY) --resource-suffix=-xxx --extend-css z.css x.rs
[ -e $(TOOLCHAIN_ONLY)/storage-xxx.js ]
! [ -e $(TOOLCHAIN_ONLY)/SourceSerif4-It.ttf.woff ]
! [ -e $(TOOLCHAIN_ONLY)/SourceSerif4-It.ttf.woff2 ]
! [ -e $(TOOLCHAIN_ONLY)/search-index-xxx.js ]
! [ -e $(TOOLCHAIN_ONLY)/x/index.html ]
! [ -e $(TOOLCHAIN_ONLY)/theme.css ]
Expand All @@ -35,7 +35,7 @@ toolchain-only:
all-shared:
$(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources,unversioned-shared-resources --output $(ALL_SHARED) --resource-suffix=-xxx --extend-css z.css x.rs
[ -e $(ALL_SHARED)/storage-xxx.js ]
[ -e $(ALL_SHARED)/SourceSerif4-It.ttf.woff ]
[ -e $(ALL_SHARED)/SourceSerif4-It.ttf.woff2 ]
! [ -e $(ALL_SHARED)/search-index-xxx.js ]
! [ -e $(ALL_SHARED)/settings.html ]
! [ -e $(ALL_SHARED)/x ]
Expand Down

0 comments on commit 2381897

Please sign in to comment.