Skip to content

Commit 15efed4

Browse files
Rollup merge of #75438 - Cldfire:rustdoc/use-adaptive-svg-favicon, r=GuillaumeGomez
Use adaptive SVG favicon for rustdoc like other rust sites Use the theme-adaptive SVG favicon that was recently introduced [for the Rust site](rust-lang/www.rust-lang.org#1185) (and others). (This PR is simply copied from the PR linked above, so see that for rationale.) Closes #72165. Before, Firefox on Linux: ![image](https://user-images.githubusercontent.com/13814214/89971811-34c0a900-dc2a-11ea-9aa6-a4aa9d66bed4.png) After, Firefox on Linux (`prefers-color-scheme` set to `dark` by setting `ui.systemUsesDarkTheme` to a number value of `1` in `about:config`): ![image](https://user-images.githubusercontent.com/13814214/89971842-515ce100-dc2a-11ea-92e8-c374aaaf6031.png)
2 parents e599b53 + 085679c commit 15efed4

File tree

7 files changed

+34
-4
lines changed

7 files changed

+34
-4
lines changed

src/librustdoc/html/layout.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ pub fn render<T: Print, S: Print>(
158158
keywords = page.keywords,
159159
favicon = if layout.favicon.is_empty() {
160160
format!(
161-
r#"<link rel="shortcut icon" href="{static_root_path}favicon{suffix}.ico">"#,
161+
r##"<link rel="icon" type="image/svg+xml" href="{static_root_path}favicon{suffix}.svg">
162+
<link rel="alternate icon" type="image/png" href="{static_root_path}favicon-16x16{suffix}.png">
163+
<link rel="alternate icon" type="image/png" href="{static_root_path}favicon-32x32{suffix}.png">"##,
162164
static_root_path = static_root_path,
163165
suffix = page.resource_suffix
164166
)

src/librustdoc/html/render/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,9 @@ fn write_shared(
754754
write(cx.path("rust-logo.png"), static_files::RUST_LOGO)?;
755755
}
756756
if (*cx.shared).layout.favicon.is_empty() {
757-
write(cx.path("favicon.ico"), static_files::RUST_FAVICON)?;
757+
write(cx.path("favicon.svg"), static_files::RUST_FAVICON_SVG)?;
758+
write(cx.path("favicon-16x16.png"), static_files::RUST_FAVICON_PNG_16)?;
759+
write(cx.path("favicon-32x32.png"), static_files::RUST_FAVICON_PNG_32)?;
758760
}
759761
write(cx.path("brush.svg"), static_files::BRUSH_SVG)?;
760762
write(cx.path("wheel.svg"), static_files::WHEEL_SVG)?;
2.16 KB
Loading
2.85 KB
Loading
-22.7 KB
Binary file not shown.
+24
Loading

src/librustdoc/html/static_files.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ pub static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt");
5353

5454
/// The contents of `rust-logo.png`, the default icon of the documentation.
5555
pub static RUST_LOGO: &[u8] = include_bytes!("static/rust-logo.png");
56-
/// The contents of `favicon.ico`, the default favicon of the documentation.
57-
pub static RUST_FAVICON: &[u8] = include_bytes!("static/favicon.ico");
56+
/// The default documentation favicons (SVG and PNG fallbacks)
57+
pub static RUST_FAVICON_SVG: &[u8] = include_bytes!("static/favicon.svg");
58+
pub static RUST_FAVICON_PNG_16: &[u8] = include_bytes!("static/favicon-16x16.png");
59+
pub static RUST_FAVICON_PNG_32: &[u8] = include_bytes!("static/favicon-32x32.png");
5860

5961
/// The built-in themes given to every documentation site.
6062
pub mod themes {

0 commit comments

Comments
 (0)