Skip to content

Commit 2381897

Browse files
authored
Rollup merge of #96279 - GuillaumeGomez:remove-woff-fonts, r=camelid,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`
2 parents 93db30a + 5c1965a commit 2381897

14 files changed

+33
-88
lines changed

src/librustdoc/html/render/write_shared.rs

+9-18
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,18 @@ use crate::{try_err, try_none};
2121

2222
static FILES_UNVERSIONED: Lazy<FxHashMap<&str, &[u8]>> = Lazy::new(|| {
2323
map! {
24-
"FiraSans-Regular.woff2" => static_files::fira_sans::REGULAR2,
25-
"FiraSans-Medium.woff2" => static_files::fira_sans::MEDIUM2,
26-
"FiraSans-Regular.woff" => static_files::fira_sans::REGULAR,
27-
"FiraSans-Medium.woff" => static_files::fira_sans::MEDIUM,
24+
"FiraSans-Regular.woff2" => static_files::fira_sans::REGULAR,
25+
"FiraSans-Medium.woff2" => static_files::fira_sans::MEDIUM,
2826
"FiraSans-LICENSE.txt" => static_files::fira_sans::LICENSE,
29-
"SourceSerif4-Regular.ttf.woff2" => static_files::source_serif_4::REGULAR2,
30-
"SourceSerif4-Bold.ttf.woff2" => static_files::source_serif_4::BOLD2,
31-
"SourceSerif4-It.ttf.woff2" => static_files::source_serif_4::ITALIC2,
32-
"SourceSerif4-Regular.ttf.woff" => static_files::source_serif_4::REGULAR,
33-
"SourceSerif4-Bold.ttf.woff" => static_files::source_serif_4::BOLD,
34-
"SourceSerif4-It.ttf.woff" => static_files::source_serif_4::ITALIC,
27+
"SourceSerif4-Regular.ttf.woff2" => static_files::source_serif_4::REGULAR,
28+
"SourceSerif4-Bold.ttf.woff2" => static_files::source_serif_4::BOLD,
29+
"SourceSerif4-It.ttf.woff2" => static_files::source_serif_4::ITALIC,
3530
"SourceSerif4-LICENSE.md" => static_files::source_serif_4::LICENSE,
36-
"SourceCodePro-Regular.ttf.woff2" => static_files::source_code_pro::REGULAR2,
37-
"SourceCodePro-Semibold.ttf.woff2" => static_files::source_code_pro::SEMIBOLD2,
38-
"SourceCodePro-It.ttf.woff2" => static_files::source_code_pro::ITALIC2,
39-
"SourceCodePro-Regular.ttf.woff" => static_files::source_code_pro::REGULAR,
40-
"SourceCodePro-Semibold.ttf.woff" => static_files::source_code_pro::SEMIBOLD,
41-
"SourceCodePro-It.ttf.woff" => static_files::source_code_pro::ITALIC,
31+
"SourceCodePro-Regular.ttf.woff2" => static_files::source_code_pro::REGULAR,
32+
"SourceCodePro-Semibold.ttf.woff2" => static_files::source_code_pro::SEMIBOLD,
33+
"SourceCodePro-It.ttf.woff2" => static_files::source_code_pro::ITALIC,
4234
"SourceCodePro-LICENSE.txt" => static_files::source_code_pro::LICENSE,
43-
"NanumBarunGothic.ttf.woff2" => static_files::nanum_barun_gothic::REGULAR2,
44-
"NanumBarunGothic.ttf.woff" => static_files::nanum_barun_gothic::REGULAR,
35+
"NanumBarunGothic.ttf.woff2" => static_files::nanum_barun_gothic::REGULAR,
4536
"NanumBarunGothic-LICENSE.txt" => static_files::nanum_barun_gothic::LICENSE,
4637
"LICENSE-MIT.txt" => static_files::LICENSE_MIT,
4738
"LICENSE-APACHE.txt" => static_files::LICENSE_APACHE,

src/librustdoc/html/static/COPYRIGHT.txt

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ These documentation pages include resources by third parties. This copyright
22
file applies only to those resources. The following third party resources are
33
included, and carry their own copyright notices and license terms:
44

5-
* Fira Sans (FiraSans-Regular.woff2, FiraSans-Medium.woff2,
6-
FiraSans-Regular.woff, FiraSans-Medium.woff):
5+
* Fira Sans (FiraSans-Regular.woff2, FiraSans-Medium.woff2):
76

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

2726
* Source Code Pro (SourceCodePro-Regular.ttf.woff2,
28-
SourceCodePro-Semibold.ttf.woff2, SourceCodePro-It.ttf.woff2,
29-
SourceCodePro-Regular.ttf.woff, SourceCodePro-Semibold.ttf.woff,
30-
SourceCodePro-It.ttf.woff):
27+
SourceCodePro-Semibold.ttf.woff2, SourceCodePro-It.ttf.woff2):
3128

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

3936
* Source Serif 4 (SourceSerif4-Regular.ttf.woff2, SourceSerif4-Bold.ttf.woff2,
40-
SourceSerif4-It.ttf.woff2, SourceSerif4-Regular.ttf.woff,
41-
SourceSerif4-Bold.ttf.woff, SourceSerif4-It.ttf.woff):
37+
SourceSerif4-It.ttf.woff2):
4238

4339
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name
4440
'Source'. All Rights Reserved. Source is a trademark of Adobe in the United

src/librustdoc/html/static/css/rustdoc.css

+9-18
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
font-style: normal;
55
font-weight: 400;
66
src: local('Fira Sans'),
7-
url("FiraSans-Regular.woff2") format("woff2"),
8-
url("FiraSans-Regular.woff") format('woff');
7+
url("FiraSans-Regular.woff2") format("woff2");
98
font-display: swap;
109
}
1110
@font-face {
1211
font-family: 'Fira Sans';
1312
font-style: normal;
1413
font-weight: 500;
1514
src: local('Fira Sans Medium'),
16-
url("FiraSans-Medium.woff2") format("woff2"),
17-
url("FiraSans-Medium.woff") format('woff');
15+
url("FiraSans-Medium.woff2") format("woff2");
1816
font-display: swap;
1917
}
2018

@@ -24,26 +22,23 @@
2422
font-style: normal;
2523
font-weight: 400;
2624
src: local('Source Serif 4'),
27-
url("SourceSerif4-Regular.ttf.woff2") format("woff2"),
28-
url("SourceSerif4-Regular.ttf.woff") format("woff");
25+
url("SourceSerif4-Regular.ttf.woff2") format("woff2");
2926
font-display: swap;
3027
}
3128
@font-face {
3229
font-family: 'Source Serif 4';
3330
font-style: italic;
3431
font-weight: 400;
3532
src: local('Source Serif 4 Italic'),
36-
url("SourceSerif4-It.ttf.woff2") format("woff2"),
37-
url("SourceSerif4-It.ttf.woff") format("woff");
33+
url("SourceSerif4-It.ttf.woff2") format("woff2");
3834
font-display: swap;
3935
}
4036
@font-face {
4137
font-family: 'Source Serif 4';
4238
font-style: normal;
4339
font-weight: 700;
4440
src: local('Source Serif 4 Bold'),
45-
url("SourceSerif4-Bold.ttf.woff2") format("woff2"),
46-
url("SourceSerif4-Bold.ttf.woff") format("woff");
41+
url("SourceSerif4-Bold.ttf.woff2") format("woff2");
4742
font-display: swap;
4843
}
4944

@@ -54,32 +49,28 @@
5449
font-weight: 400;
5550
/* Avoid using locally installed font because bad versions are in circulation:
5651
* see https://github.com/rust-lang/rust/issues/24355 */
57-
src: url("SourceCodePro-Regular.ttf.woff2") format("woff2"),
58-
url("SourceCodePro-Regular.ttf.woff") format("woff");
52+
src: url("SourceCodePro-Regular.ttf.woff2") format("woff2");
5953
font-display: swap;
6054
}
6155
@font-face {
6256
font-family: 'Source Code Pro';
6357
font-style: italic;
6458
font-weight: 400;
65-
src: url("SourceCodePro-It.ttf.woff2") format("woff2"),
66-
url("SourceCodePro-It.ttf.woff") format("woff");
59+
src: url("SourceCodePro-It.ttf.woff2") format("woff2");
6760
font-display: swap;
6861
}
6962
@font-face {
7063
font-family: 'Source Code Pro';
7164
font-style: normal;
7265
font-weight: 600;
73-
src: url("SourceCodePro-Semibold.ttf.woff2") format("woff2"),
74-
url("SourceCodePro-Semibold.ttf.woff") format("woff");
66+
src: url("SourceCodePro-Semibold.ttf.woff2") format("woff2");
7567
font-display: swap;
7668
}
7769

7870
/* Avoid using legacy CJK serif fonts in Windows like Batang. */
7971
@font-face {
8072
font-family: 'NanumBarunGothic';
81-
src: url("NanumBarunGothic.ttf.woff2") format("woff2"),
82-
url("NanumBarunGothic.ttf.woff") format("woff");
73+
src: url("NanumBarunGothic.ttf.woff2") format("woff2");
8374
font-display: swap;
8475
unicode-range: U+AC00-D7AF, U+1100-11FF, U+3130-318F, U+A960-A97F, U+D7B0-D7FF;
8576
}
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.

src/librustdoc/html/static_files.rs

+9-42
Original file line numberDiff line numberDiff line change
@@ -92,72 +92,47 @@ crate mod themes {
9292

9393
/// Files related to the Fira Sans font.
9494
crate mod fira_sans {
95-
/// The file `FiraSans-Regular.woff`, the Regular variant of the Fira Sans font.
96-
crate static REGULAR: &[u8] = include_bytes!("static/fonts/FiraSans-Regular.woff");
97-
9895
/// The file `FiraSans-Regular.woff2`, the Regular variant of the Fira Sans font in woff2.
99-
crate static REGULAR2: &[u8] = include_bytes!("static/fonts/FiraSans-Regular.woff2");
100-
101-
/// The file `FiraSans-Medium.woff`, the Medium variant of the Fira Sans font.
102-
crate static MEDIUM: &[u8] = include_bytes!("static/fonts/FiraSans-Medium.woff");
96+
crate static REGULAR: &[u8] = include_bytes!("static/fonts/FiraSans-Regular.woff2");
10397

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

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

111105
/// Files related to the Source Serif 4 font.
112106
crate mod source_serif_4 {
113-
/// The file `SourceSerif4-Regular.ttf.woff`, the Regular variant of the Source Serif 4 font.
114-
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceSerif4-Regular.ttf.woff");
115-
116107
/// The file `SourceSerif4-Regular.ttf.woff2`, the Regular variant of the Source Serif 4 font in
117108
/// woff2.
118-
crate static REGULAR2: &[u8] = include_bytes!("static/fonts/SourceSerif4-Regular.ttf.woff2");
119-
120-
/// The file `SourceSerif4-Bold.ttf.woff`, the Bold variant of the Source Serif 4 font.
121-
crate static BOLD: &[u8] = include_bytes!("static/fonts/SourceSerif4-Bold.ttf.woff");
109+
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceSerif4-Regular.ttf.woff2");
122110

123111
/// The file `SourceSerif4-Bold.ttf.woff2`, the Bold variant of the Source Serif 4 font in
124112
/// woff2.
125-
crate static BOLD2: &[u8] = include_bytes!("static/fonts/SourceSerif4-Bold.ttf.woff2");
126-
127-
/// The file `SourceSerif4-It.ttf.woff`, the Italic variant of the Source Serif 4 font.
128-
crate static ITALIC: &[u8] = include_bytes!("static/fonts/SourceSerif4-It.ttf.woff");
113+
crate static BOLD: &[u8] = include_bytes!("static/fonts/SourceSerif4-Bold.ttf.woff2");
129114

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

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

138123
/// Files related to the Source Code Pro font.
139124
crate mod source_code_pro {
140-
/// The file `SourceCodePro-Regular.ttf.woff`, the Regular variant of the Source Code Pro font.
141-
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceCodePro-Regular.ttf.woff");
142-
143125
/// The file `SourceCodePro-Regular.ttf.woff2`, the Regular variant of the Source Code Pro font
144126
/// in woff2.
145-
crate static REGULAR2: &[u8] = include_bytes!("static/fonts/SourceCodePro-Regular.ttf.woff2");
146-
147-
/// The file `SourceCodePro-Semibold.ttf.woff`, the Semibold variant of the Source Code Pro
148-
/// font.
149-
crate static SEMIBOLD: &[u8] = include_bytes!("static/fonts/SourceCodePro-Semibold.ttf.woff");
127+
crate static REGULAR: &[u8] = include_bytes!("static/fonts/SourceCodePro-Regular.ttf.woff2");
150128

151129
/// The file `SourceCodePro-Semibold.ttf.woff2`, the Semibold variant of the Source Code Pro
152130
/// font in woff2.
153-
crate static SEMIBOLD2: &[u8] = include_bytes!("static/fonts/SourceCodePro-Semibold.ttf.woff2");
154-
155-
/// The file `SourceCodePro-It.ttf.woff`, the Italic variant of the Source Code Pro font.
156-
crate static ITALIC: &[u8] = include_bytes!("static/fonts/SourceCodePro-It.ttf.woff");
131+
crate static SEMIBOLD: &[u8] = include_bytes!("static/fonts/SourceCodePro-Semibold.ttf.woff2");
157132

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

162137
/// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font.
163138
crate static LICENSE: &[u8] = include_bytes!("static/fonts/SourceCodePro-LICENSE.txt");
@@ -176,19 +151,11 @@ crate mod source_code_pro {
176151
/// ```sh
177152
/// pyftsubset NanumBarunGothic.ttf \
178153
/// --unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
179-
/// --output-file=NanumBarunGothic.ttf.woff --flavor=woff
180-
/// ```
181-
/// ```sh
182-
/// pyftsubset NanumBarunGothic.ttf \
183-
/// --unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
184154
/// --output-file=NanumBarunGothic.ttf.woff2 --flavor=woff2
185155
/// ```
186156
crate mod nanum_barun_gothic {
187-
/// The file `NanumBarunGothic.ttf.woff`, the Regular variant of the Nanum Barun Gothic font.
188-
crate static REGULAR: &[u8] = include_bytes!("static/fonts/NanumBarunGothic.ttf.woff");
189-
190157
/// The file `NanumBarunGothic.ttf.woff2`, the Regular variant of the Nanum Barun Gothic font.
191-
crate static REGULAR2: &[u8] = include_bytes!("static/fonts/NanumBarunGothic.ttf.woff2");
158+
crate static REGULAR: &[u8] = include_bytes!("static/fonts/NanumBarunGothic.ttf.woff2");
192159

193160
/// The file `NanumBarunGothic-LICENSE.txt`, the license text of the Nanum Barun Gothic font.
194161
crate static LICENSE: &[u8] = include_bytes!("static/fonts/NanumBarunGothic-LICENSE.txt");

src/test/run-make/emit-shared-files/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ invocation-only:
1414
[ -e $(INVOCATION_ONLY)/x/index.html ]
1515
[ -e $(INVOCATION_ONLY)/theme-xxx.css ] # generated from z.css
1616
! [ -e $(INVOCATION_ONLY)/storage-xxx.js ]
17-
! [ -e $(INVOCATION_ONLY)/SourceSerif4-It.ttf.woff ]
17+
! [ -e $(INVOCATION_ONLY)/SourceSerif4-It.ttf.woff2 ]
1818

1919
# FIXME: this probably shouldn't have a suffix
2020
[ -e $(INVOCATION_ONLY)/y-xxx.css ]
@@ -24,7 +24,7 @@ invocation-only:
2424
toolchain-only:
2525
$(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources --output $(TOOLCHAIN_ONLY) --resource-suffix=-xxx --extend-css z.css x.rs
2626
[ -e $(TOOLCHAIN_ONLY)/storage-xxx.js ]
27-
! [ -e $(TOOLCHAIN_ONLY)/SourceSerif4-It.ttf.woff ]
27+
! [ -e $(TOOLCHAIN_ONLY)/SourceSerif4-It.ttf.woff2 ]
2828
! [ -e $(TOOLCHAIN_ONLY)/search-index-xxx.js ]
2929
! [ -e $(TOOLCHAIN_ONLY)/x/index.html ]
3030
! [ -e $(TOOLCHAIN_ONLY)/theme.css ]
@@ -35,7 +35,7 @@ toolchain-only:
3535
all-shared:
3636
$(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources,unversioned-shared-resources --output $(ALL_SHARED) --resource-suffix=-xxx --extend-css z.css x.rs
3737
[ -e $(ALL_SHARED)/storage-xxx.js ]
38-
[ -e $(ALL_SHARED)/SourceSerif4-It.ttf.woff ]
38+
[ -e $(ALL_SHARED)/SourceSerif4-It.ttf.woff2 ]
3939
! [ -e $(ALL_SHARED)/search-index-xxx.js ]
4040
! [ -e $(ALL_SHARED)/settings.html ]
4141
! [ -e $(ALL_SHARED)/x ]

0 commit comments

Comments
 (0)