Skip to content

Commit 1738c78

Browse files
committed
rustdoc: add optional woff2 versions of Source Serif and Source Code
1 parent 0ef2b4a commit 1738c78

9 files changed

+45
-6
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,
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
@@ -100,12 +100,24 @@ crate mod source_serif_4 {
100100
/// The file `SourceSerif4-Regular.ttf.woff`, the Regular variant of the Source Serif 4 font.
101101
crate static REGULAR: &[u8] = include_bytes!("static/SourceSerif4-Regular.ttf.woff");
102102

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

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

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

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

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

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

0 commit comments

Comments
 (0)