diff --git a/crates/mdbook-core/src/config.rs b/crates/mdbook-core/src/config.rs
index fcae567107..d5746971b2 100644
--- a/crates/mdbook-core/src/config.rs
+++ b/crates/mdbook-core/src/config.rs
@@ -411,7 +411,7 @@ pub enum RustEdition {
}
/// Configuration for the HTML renderer.
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case", deny_unknown_fields)]
#[non_exhaustive]
pub struct HtmlConfig {
@@ -426,8 +426,6 @@ pub struct HtmlConfig {
pub smart_punctuation: bool,
/// Should mathjax be enabled?
pub mathjax_support: bool,
- /// Whether to fonts.css and respective font files to the output directory.
- pub copy_fonts: bool,
/// Additional CSS stylesheets to include in the rendered page's `
`.
pub additional_css: Vec,
/// Additional JS scripts to include at the bottom of the rendered page's
@@ -481,36 +479,6 @@ pub struct HtmlConfig {
pub hash_files: bool,
}
-impl Default for HtmlConfig {
- fn default() -> HtmlConfig {
- HtmlConfig {
- theme: None,
- default_theme: None,
- preferred_dark_theme: None,
- smart_punctuation: false,
- mathjax_support: false,
- copy_fonts: true,
- additional_css: Vec::new(),
- additional_js: Vec::new(),
- fold: Fold::default(),
- playground: Playground::default(),
- code: Code::default(),
- print: Print::default(),
- no_section_label: false,
- search: None,
- git_repository_url: None,
- git_repository_icon: None,
- edit_url_template: None,
- input_404: None,
- site_url: None,
- cname: None,
- live_reload_endpoint: None,
- redirect: HashMap::new(),
- hash_files: false,
- }
- }
-}
-
impl HtmlConfig {
/// Returns the directory of theme from the provided root directory. If the
/// directory is not present it will append the default directory of "theme"
diff --git a/crates/mdbook-html/front-end/templates/index.hbs b/crates/mdbook-html/front-end/templates/index.hbs
index e4fa64a3db..5482448913 100644
--- a/crates/mdbook-html/front-end/templates/index.hbs
+++ b/crates/mdbook-html/front-end/templates/index.hbs
@@ -34,9 +34,7 @@
- {{#if copy_fonts}}
- {{/if}}
diff --git a/crates/mdbook-html/front-end/templates/toc.html.hbs b/crates/mdbook-html/front-end/templates/toc.html.hbs
index 93dea2569c..693e16cef9 100644
--- a/crates/mdbook-html/front-end/templates/toc.html.hbs
+++ b/crates/mdbook-html/front-end/templates/toc.html.hbs
@@ -29,9 +29,7 @@
{{/if}}
- {{#if copy_fonts}}
- {{/if}}
{{#each additional_css}}
diff --git a/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs b/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs
index c2f34e3594..b2c0ecaf0b 100644
--- a/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs
+++ b/crates/mdbook-html/src/html_handlebars/hbs_renderer.rs
@@ -557,11 +557,6 @@ fn make_data(
data.insert("mathjax_support".to_owned(), json!(true));
}
- // This `matches!` checks for a non-empty file.
- if html_config.copy_fonts || matches!(theme.fonts_css.as_deref(), Some([_, ..])) {
- data.insert("copy_fonts".to_owned(), json!(true));
- }
-
// Add check to see if there is an additional style
if !html_config.additional_css.is_empty() {
let mut css = Vec::new();
diff --git a/crates/mdbook-html/src/html_handlebars/static_files.rs b/crates/mdbook-html/src/html_handlebars/static_files.rs
index f9d06f3a32..5969c3e6a6 100644
--- a/crates/mdbook-html/src/html_handlebars/static_files.rs
+++ b/crates/mdbook-html/src/html_handlebars/static_files.rs
@@ -3,7 +3,7 @@
use super::helpers::resources::ResourceHelper;
use crate::theme::{self, Theme, playground_editor};
use anyhow::{Context, Result};
-use log::{debug, warn};
+use log::debug;
use mdbook_core::config::HtmlConfig;
use mdbook_core::utils;
use std::borrow::Cow;
@@ -84,7 +84,7 @@ impl StaticFiles {
theme::FONT_AWESOME_WOFF2,
);
this.add_builtin("FontAwesome/fonts/FontAwesome.ttf", theme::FONT_AWESOME_TTF);
- if html_config.copy_fonts && theme.fonts_css.is_none() {
+ if theme.fonts_css.is_none() {
this.add_builtin("fonts/fonts.css", theme::fonts::CSS);
for (file_name, contents) in theme::fonts::LICENSES.iter() {
this.add_builtin(file_name, contents);
@@ -101,13 +101,6 @@ impl StaticFiles {
this.add_builtin("fonts/fonts.css", fonts_css);
}
}
- if !html_config.copy_fonts && theme.fonts_css.is_none() {
- warn!(
- "output.html.copy-fonts is deprecated.\n\
- This book appears to have copy-fonts=false in book.toml without a fonts.css file.\n\
- Add an empty `theme/fonts/fonts.css` file to squelch this warning."
- );
- }
let playground_config = &html_config.playground;
diff --git a/guide/src/format/configuration/renderers.md b/guide/src/format/configuration/renderers.md
index 1219f55acb..23b364277b 100644
--- a/guide/src/format/configuration/renderers.md
+++ b/guide/src/format/configuration/renderers.md
@@ -99,7 +99,6 @@ default-theme = "light"
preferred-dark-theme = "navy"
smart-punctuation = true
mathjax-support = false
-copy-fonts = true
additional-css = ["custom.css", "custom2.css"]
additional-js = ["custom.js"]
no-section-label = false
@@ -127,10 +126,6 @@ The following configuration options are available:
Defaults to `false`.
- **mathjax-support:** Adds support for [MathJax](../mathjax.md). Defaults to
`false`.
-- **copy-fonts:** (**Deprecated**) If `true` (the default), mdBook uses its built-in fonts which are copied to the output directory.
- If `false`, the built-in fonts will not be used.
- This option is deprecated. If you want to define your own custom fonts,
- create a `theme/fonts/fonts.css` file and store the fonts in the `theme/fonts/` directory.
- **additional-css:** If you need to slightly change the appearance of your book
without overwriting the whole style, you can specify a set of stylesheets that
will be loaded after the default ones where you can surgically change the
diff --git a/tests/testsuite/theme.rs b/tests/testsuite/theme.rs
index 6ef67c235a..885f7ca751 100644
--- a/tests/testsuite/theme.rs
+++ b/tests/testsuite/theme.rs
@@ -139,45 +139,26 @@ book/fonts/myfont.woff
);
}
-// copy-fonts=false, no theme, deprecated
+// Empty fonts.css should not copy the default fonts.
#[test]
-fn copy_fonts_false_no_theme() {
- BookTest::from_dir("theme/copy_fonts_false_no_theme")
+fn empty_fonts_css() {
+ BookTest::from_dir("theme/empty_fonts_css")
.run("build", |cmd| {
cmd.expect_stderr(str![[r#"
[TIMESTAMP] [INFO] (mdbook_driver::mdbook): Book building has started
[TIMESTAMP] [INFO] (mdbook_driver::mdbook): Running the html backend
-[TIMESTAMP] [WARN] (mdbook_html::html_handlebars::static_files): output.html.copy-fonts is deprecated.
-This book appears to have copy-fonts=false in book.toml without a fonts.css file.
-Add an empty `theme/fonts/fonts.css` file to squelch this warning.
[TIMESTAMP] [INFO] (mdbook_html::html_handlebars::hbs_renderer): HTML book written to `[ROOT]/book`
"#]]);
})
- .check_file_doesnt_contain("book/index.html", "fonts.css")
- .check_file_list("book/fonts", str![[""]]);
-}
-
-// copy-fonts=false, empty fonts.css
-#[test]
-fn copy_fonts_false_with_empty_fonts_css() {
- BookTest::from_dir("theme/copy_fonts_false_with_empty_fonts_css")
- .run("build", |cmd| {
- cmd.expect_stderr(str![[r#"
-[TIMESTAMP] [INFO] (mdbook_driver::mdbook): Book building has started
-[TIMESTAMP] [INFO] (mdbook_driver::mdbook): Running the html backend
-[TIMESTAMP] [INFO] (mdbook_html::html_handlebars::hbs_renderer): HTML book written to `[ROOT]/book`
-
-"#]]);
- })
- .check_file_doesnt_contain("book/index.html", "fonts.css")
+ .check_file_contains("book/index.html", "fonts.css")
.check_file_list("book/fonts", str![[""]]);
}
-// copy-fonts=false, fonts.css has contents
+// Custom fonts.css file shouldn't copy default fonts.
#[test]
-fn copy_fonts_false_with_fonts_css() {
- BookTest::from_dir("theme/copy_fonts_false_with_fonts_css")
+fn custom_fonts_css() {
+ BookTest::from_dir("theme/custom_fonts_css")
.run("build", |cmd| {
cmd.expect_stderr(str![[r#"
[TIMESTAMP] [INFO] (mdbook_driver::mdbook): Book building has started
diff --git a/tests/testsuite/theme/copy_fonts_false_no_theme/book.toml b/tests/testsuite/theme/copy_fonts_false_no_theme/book.toml
deleted file mode 100644
index e4929c83e1..0000000000
--- a/tests/testsuite/theme/copy_fonts_false_no_theme/book.toml
+++ /dev/null
@@ -1,2 +0,0 @@
-[output.html]
-copy-fonts = false
diff --git a/tests/testsuite/theme/copy_fonts_false_with_empty_fonts_css/book.toml b/tests/testsuite/theme/copy_fonts_false_with_empty_fonts_css/book.toml
deleted file mode 100644
index e4929c83e1..0000000000
--- a/tests/testsuite/theme/copy_fonts_false_with_empty_fonts_css/book.toml
+++ /dev/null
@@ -1,2 +0,0 @@
-[output.html]
-copy-fonts = false
diff --git a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/book.toml b/tests/testsuite/theme/copy_fonts_false_with_fonts_css/book.toml
deleted file mode 100644
index e4929c83e1..0000000000
--- a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/book.toml
+++ /dev/null
@@ -1,2 +0,0 @@
-[output.html]
-copy-fonts = false
diff --git a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/src/SUMMARY.md b/tests/testsuite/theme/copy_fonts_false_with_fonts_css/src/SUMMARY.md
deleted file mode 100644
index 655a0dedf8..0000000000
--- a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/src/SUMMARY.md
+++ /dev/null
@@ -1 +0,0 @@
-- [Intro](index.md)
diff --git a/tests/testsuite/theme/custom_fonts_css/book.toml b/tests/testsuite/theme/custom_fonts_css/book.toml
new file mode 100644
index 0000000000..5e8ff080fc
--- /dev/null
+++ b/tests/testsuite/theme/custom_fonts_css/book.toml
@@ -0,0 +1,2 @@
+[book]
+title = "custom_fonts_css"
diff --git a/tests/testsuite/theme/copy_fonts_false_no_theme/src/SUMMARY.md b/tests/testsuite/theme/custom_fonts_css/src/SUMMARY.md
similarity index 100%
rename from tests/testsuite/theme/copy_fonts_false_no_theme/src/SUMMARY.md
rename to tests/testsuite/theme/custom_fonts_css/src/SUMMARY.md
diff --git a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/theme/fonts/fonts.css b/tests/testsuite/theme/custom_fonts_css/theme/fonts/fonts.css
similarity index 100%
rename from tests/testsuite/theme/copy_fonts_false_with_fonts_css/theme/fonts/fonts.css
rename to tests/testsuite/theme/custom_fonts_css/theme/fonts/fonts.css
diff --git a/tests/testsuite/theme/copy_fonts_false_with_fonts_css/theme/fonts/myfont.woff b/tests/testsuite/theme/custom_fonts_css/theme/fonts/myfont.woff
similarity index 100%
rename from tests/testsuite/theme/copy_fonts_false_with_fonts_css/theme/fonts/myfont.woff
rename to tests/testsuite/theme/custom_fonts_css/theme/fonts/myfont.woff
diff --git a/tests/testsuite/theme/empty_fonts_css/book.toml b/tests/testsuite/theme/empty_fonts_css/book.toml
new file mode 100644
index 0000000000..79d6ef5c51
--- /dev/null
+++ b/tests/testsuite/theme/empty_fonts_css/book.toml
@@ -0,0 +1,2 @@
+[book]
+title = "empty_fonts_css"
diff --git a/tests/testsuite/theme/copy_fonts_false_with_empty_fonts_css/src/SUMMARY.md b/tests/testsuite/theme/empty_fonts_css/src/SUMMARY.md
similarity index 100%
rename from tests/testsuite/theme/copy_fonts_false_with_empty_fonts_css/src/SUMMARY.md
rename to tests/testsuite/theme/empty_fonts_css/src/SUMMARY.md
diff --git a/tests/testsuite/theme/copy_fonts_false_with_empty_fonts_css/theme/fonts/fonts.css b/tests/testsuite/theme/empty_fonts_css/theme/fonts/fonts.css
similarity index 100%
rename from tests/testsuite/theme/copy_fonts_false_with_empty_fonts_css/theme/fonts/fonts.css
rename to tests/testsuite/theme/empty_fonts_css/theme/fonts/fonts.css