Skip to content

Commit fd96d55

Browse files
authored
Rollup merge of #86402 - tspiteri:source-woff2, r=jsha
rustdoc: add optional woff2 versions of Source Serif and Source Code This provides woff2 versions of Source Serif and Source Code similar to how #82545 provides woff2 versions of Fira Sans. The total byte count for the six files (three for each font family) is reduced by 25% from 476 KiB to 358 KiB.
2 parents 0cfaa27 + a7d2061 commit fd96d55

10 files changed

+54
-11
lines changed

src/librustdoc/html/render/write_shared.rs

+6
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ static FILES_UNVERSIONED: Lazy<FxHashMap<&str, &[u8]>> = Lazy::new(|| {
2525
"FiraSans-Regular.woff" => static_files::fira_sans::REGULAR,
2626
"FiraSans-Medium.woff" => static_files::fira_sans::MEDIUM,
2727
"FiraSans-LICENSE.txt" => static_files::fira_sans::LICENSE,
28+
"SourceSerif4-Regular.ttf.woff2" => static_files::source_serif_4::REGULAR2,
29+
"SourceSerif4-Bold.ttf.woff2" => static_files::source_serif_4::BOLD2,
30+
"SourceSerif4-It.ttf.woff2" => static_files::source_serif_4::ITALIC2,
2831
"SourceSerif4-Regular.ttf.woff" => static_files::source_serif_4::REGULAR,
2932
"SourceSerif4-Bold.ttf.woff" => static_files::source_serif_4::BOLD,
3033
"SourceSerif4-It.ttf.woff" => static_files::source_serif_4::ITALIC,
3134
"SourceSerif4-LICENSE.md" => static_files::source_serif_4::LICENSE,
35+
"SourceCodePro-Regular.ttf.woff2" => static_files::source_code_pro::REGULAR2,
36+
"SourceCodePro-Semibold.ttf.woff2" => static_files::source_code_pro::SEMIBOLD2,
37+
"SourceCodePro-It.ttf.woff2" => static_files::source_code_pro::ITALIC2,
3238
"SourceCodePro-Regular.ttf.woff" => static_files::source_code_pro::REGULAR,
3339
"SourceCodePro-Semibold.ttf.woff" => static_files::source_code_pro::SEMIBOLD,
3440
"SourceCodePro-It.ttf.woff" => static_files::source_code_pro::ITALIC,

src/librustdoc/html/static/COPYRIGHT.txt

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ 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.woff, FiraSans-Medium.woff):
5+
* Fira Sans (FiraSans-Regular.woff2, FiraSans-Medium.woff2,
6+
FiraSans-Regular.woff, FiraSans-Medium.woff):
67

78
Copyright (c) 2014, Mozilla Foundation https://mozilla.org/
89
with Reserved Font Name Fira Sans.
@@ -23,8 +24,10 @@ included, and carry their own copyright notices and license terms:
2324
Copyright (c) Nicolas Gallagher and Jonathan Neal.
2425
Licensed under the MIT license (see LICENSE-MIT.txt).
2526

26-
* Source Code Pro (SourceCodePro-Regular.ttf.woff,
27-
SourceCodePro-Semibold.ttf.woff, SourceCodePro-It.ttf.woff):
27+
* 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):
2831

2932
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
3033
with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark
@@ -33,8 +36,9 @@ included, and carry their own copyright notices and license terms:
3336
Licensed under the SIL Open Font License, Version 1.1.
3437
See SourceCodePro-LICENSE.txt.
3538

36-
* Source Serif 4 (SourceSerif4-Regular.ttf.woff, SourceSerif4-Bold.ttf.woff,
37-
SourceSerif4-It.ttf.woff):
39+
* 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):
3842

3943
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name
4044
'Source'. All Rights Reserved. Source is a trademark of Adobe in the United
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/rustdoc.css

+15-6
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,27 @@
2323
font-family: 'Source Serif 4';
2424
font-style: normal;
2525
font-weight: 400;
26-
src: local('Source Serif 4'), url("SourceSerif4-Regular.ttf.woff") format('woff');
26+
src: local('Source Serif 4'),
27+
url("SourceSerif4-Regular.ttf.woff2") format("woff2"),
28+
url("SourceSerif4-Regular.ttf.woff") format("woff");
2729
font-display: swap;
2830
}
2931
@font-face {
3032
font-family: 'Source Serif 4';
3133
font-style: italic;
3234
font-weight: 400;
33-
src: local('Source Serif 4 Italic'), url("SourceSerif4-It.ttf.woff") format('woff');
35+
src: local('Source Serif 4 Italic'),
36+
url("SourceSerif4-It.ttf.woff2") format("woff2"),
37+
url("SourceSerif4-It.ttf.woff") format("woff");
3438
font-display: swap;
3539
}
3640
@font-face {
3741
font-family: 'Source Serif 4';
3842
font-style: normal;
3943
font-weight: 700;
40-
src: local('Source Serif 4 Bold'), url("SourceSerif4-Bold.ttf.woff") format('woff');
44+
src: local('Source Serif 4 Bold'),
45+
url("SourceSerif4-Bold.ttf.woff2") format("woff2"),
46+
url("SourceSerif4-Bold.ttf.woff") format("woff");
4147
font-display: swap;
4248
}
4349

@@ -48,21 +54,24 @@
4854
font-weight: 400;
4955
/* Avoid using locally installed font because bad versions are in circulation:
5056
* see https://github.com/rust-lang/rust/issues/24355 */
51-
src: url("SourceCodePro-Regular.ttf.woff") format('woff');
57+
src: url("SourceCodePro-Regular.ttf.woff2") format("woff2"),
58+
url("SourceCodePro-Regular.ttf.woff") format("woff");
5259
font-display: swap;
5360
}
5461
@font-face {
5562
font-family: 'Source Code Pro';
5663
font-style: italic;
5764
font-weight: 400;
58-
src: url("SourceCodePro-It.ttf.woff") format('woff');
65+
src: url("SourceCodePro-It.ttf.woff2") format("woff2"),
66+
url("SourceCodePro-It.ttf.woff") format("woff");
5967
font-display: swap;
6068
}
6169
@font-face {
6270
font-family: 'Source Code Pro';
6371
font-style: normal;
6472
font-weight: 600;
65-
src: url("SourceCodePro-Semibold.ttf.woff") format('woff');
73+
src: url("SourceCodePro-Semibold.ttf.woff2") format("woff2"),
74+
url("SourceCodePro-Semibold.ttf.woff") format("woff");
6675
font-display: swap;
6776
}
6877

src/librustdoc/html/static_files.rs

+24
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,24 @@ crate mod source_serif_4 {
102102
/// The file `SourceSerif4-Regular.ttf.woff`, the Regular variant of the Source Serif 4 font.
103103
crate static REGULAR: &[u8] = include_bytes!("static/SourceSerif4-Regular.ttf.woff");
104104

105+
/// The file `SourceSerif4-Regular.ttf.woff2`, the Regular variant of the Source Serif 4 font in
106+
/// woff2.
107+
crate static REGULAR2: &[u8] = include_bytes!("static/SourceSerif4-Regular.ttf.woff2");
108+
105109
/// The file `SourceSerif4-Bold.ttf.woff`, the Bold variant of the Source Serif 4 font.
106110
crate static BOLD: &[u8] = include_bytes!("static/SourceSerif4-Bold.ttf.woff");
107111

112+
/// The file `SourceSerif4-Bold.ttf.woff2`, the Bold variant of the Source Serif 4 font in
113+
/// woff2.
114+
crate static BOLD2: &[u8] = include_bytes!("static/SourceSerif4-Bold.ttf.woff2");
115+
108116
/// The file `SourceSerif4-It.ttf.woff`, the Italic variant of the Source Serif 4 font.
109117
crate static ITALIC: &[u8] = include_bytes!("static/SourceSerif4-It.ttf.woff");
110118

119+
/// The file `SourceSerif4-It.ttf.woff2`, the Italic variant of the Source Serif 4 font in
120+
/// woff2.
121+
crate static ITALIC2: &[u8] = include_bytes!("static/SourceSerif4-It.ttf.woff2");
122+
111123
/// The file `SourceSerif4-LICENSE.txt`, the license text for the Source Serif 4 font.
112124
crate static LICENSE: &[u8] = include_bytes!("static/SourceSerif4-LICENSE.md");
113125
}
@@ -117,13 +129,25 @@ crate mod source_code_pro {
117129
/// The file `SourceCodePro-Regular.ttf.woff`, the Regular variant of the Source Code Pro font.
118130
crate static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.ttf.woff");
119131

132+
/// The file `SourceCodePro-Regular.ttf.woff2`, the Regular variant of the Source Code Pro font
133+
/// in woff2.
134+
crate static REGULAR2: &[u8] = include_bytes!("static/SourceCodePro-Regular.ttf.woff2");
135+
120136
/// The file `SourceCodePro-Semibold.ttf.woff`, the Semibold variant of the Source Code Pro
121137
/// font.
122138
crate static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.ttf.woff");
123139

140+
/// The file `SourceCodePro-Semibold.ttf.woff2`, the Semibold variant of the Source Code Pro
141+
/// font in woff2.
142+
crate static SEMIBOLD2: &[u8] = include_bytes!("static/SourceCodePro-Semibold.ttf.woff2");
143+
124144
/// The file `SourceCodePro-It.ttf.woff`, the Italic variant of the Source Code Pro font.
125145
crate static ITALIC: &[u8] = include_bytes!("static/SourceCodePro-It.ttf.woff");
126146

147+
/// The file `SourceCodePro-It.ttf.woff2`, the Italic variant of the Source Code Pro font in
148+
/// woff2.
149+
crate static ITALIC2: &[u8] = include_bytes!("static/SourceCodePro-It.ttf.woff2");
150+
127151
/// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font.
128152
crate static LICENSE: &[u8] = include_bytes!("static/SourceCodePro-LICENSE.txt");
129153
}

0 commit comments

Comments
 (0)