Don't copy the stock fonts if the user has overridden fonts.css.
This wasn't behaving as I was really intending.
This commit is contained in:
parent
75a6d65e5a
commit
01047846a9
|
@ -275,7 +275,8 @@ impl HtmlHandlebars {
|
||||||
"FontAwesome/fonts/FontAwesome.ttf",
|
"FontAwesome/fonts/FontAwesome.ttf",
|
||||||
theme::FONT_AWESOME_TTF,
|
theme::FONT_AWESOME_TTF,
|
||||||
)?;
|
)?;
|
||||||
if html_config.copy_fonts {
|
// Don't copy the stock fonts if the user has specified their own fonts to use.
|
||||||
|
if html_config.copy_fonts && theme.fonts_css.is_none() {
|
||||||
write_file(destination, "fonts/fonts.css", theme::fonts::CSS)?;
|
write_file(destination, "fonts/fonts.css", theme::fonts::CSS)?;
|
||||||
for (file_name, contents) in theme::fonts::LICENSES.iter() {
|
for (file_name, contents) in theme::fonts::LICENSES.iter() {
|
||||||
write_file(destination, file_name, contents)?;
|
write_file(destination, file_name, contents)?;
|
||||||
|
|
|
@ -891,8 +891,8 @@ fn custom_fonts() {
|
||||||
assert_eq!(actual_files(&p.join("book/fonts")), &builtin_fonts);
|
assert_eq!(actual_files(&p.join("book/fonts")), &builtin_fonts);
|
||||||
assert!(has_fonts_css(p));
|
assert!(has_fonts_css(p));
|
||||||
|
|
||||||
// Mixed with copy_fonts=true
|
// Mixed with copy-fonts=true
|
||||||
// This should generate a deprecation warning.
|
// Should ignore the copy-fonts setting since the user has provided their own fonts.css.
|
||||||
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
|
let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap();
|
||||||
let p = temp.path();
|
let p = temp.path();
|
||||||
MDBook::init(p).build().unwrap();
|
MDBook::init(p).build().unwrap();
|
||||||
|
@ -900,10 +900,10 @@ fn custom_fonts() {
|
||||||
write_file(&p.join("theme/fonts"), "myfont.woff", b"").unwrap();
|
write_file(&p.join("theme/fonts"), "myfont.woff", b"").unwrap();
|
||||||
MDBook::load(p).unwrap().build().unwrap();
|
MDBook::load(p).unwrap().build().unwrap();
|
||||||
assert!(has_fonts_css(p));
|
assert!(has_fonts_css(p));
|
||||||
let mut expected = Vec::from(builtin_fonts);
|
assert_eq!(
|
||||||
expected.push("myfont.woff");
|
actual_files(&p.join("book/fonts")),
|
||||||
expected.sort();
|
["fonts.css", "myfont.woff"]
|
||||||
assert_eq!(actual_files(&p.join("book/fonts")), expected.as_slice());
|
);
|
||||||
|
|
||||||
// copy-fonts=false, no theme
|
// copy-fonts=false, no theme
|
||||||
// This should generate a deprecation warning.
|
// This should generate a deprecation warning.
|
||||||
|
|
Loading…
Reference in New Issue