几天前我发现了mdBook。环顾四周,寻找一个简单的,小的,没有速度的静态站点生成器,我很兴奋。它易于使用,简单,快速和完全良好的设计。
尽管设置简单、快捷,但细节仍然存在问题。我想在一个定制的主题中调整字体。
在mdBook手册中,字体配置的可能性仅在HTML呈现器选项中提到:“复制字体”配置选项将“fonts.css”和相应的字体文件复制到要在默认主题中使用的输出目录中。但是,读取“默认主题”上方的几个要点被定义为在“更改主题”下拉列表中默认选择的主题颜色方案。
这怎么合在一起?在我的配置中,字体文件的自动复制不起作用。我编写了一个bash脚本,在构建图书输出之后进行复制。
因此,我想描述一下我所做的配置步骤:
问候
彼得
发布于 2020-11-29 22:10:08
更多信息
不幸的是,上面的第一个提示并不能完全解决问题。它会产生一个效果:自定义字体css文件会自动复制到正确的子目录。它的新位置是
book/peters-theme/fonts/libertinus-sans-font.css因此,我相应地更改了文件‘peters- the /index.hbs’的修改。
<!-- Fonts -->
<link rel="stylesheet"
href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
{{#if copy_fonts}}
<!-- added additionally to include custom font CSS -->
<link rel="stylesheet"
href="{{ path_to_root }}peters-theme/fonts/libertinus-sans-font.css">
{{/if}}但问题的一部分仍然存在。本地字体文件不会复制到目标“book/fonts”目录。
环顾四周,看到满足的拉请求,我来到了这一个。在描述之后,我更改了“book.toml”配置文件,并添加了一个新的“output.html.font”部分。
[output.html.font]
enable = true
woff = true下面列出了完整的“book.toml”配置文件:
[book]
title = "Rust Never Sleeps"
description = "An adventure getting in touch with mdBook and Rust"
author = "Peter"
language = "en"
multilingual = false
src = "src"
[output.html]
theme = "peters-theme"
default-theme = "rust"
copy-fonts = true
additional-css = ["peters-theme/fonts/libertinus-sans-font.css"]
[output.html.font]
enable = true
woff = true此外,我更改了字体css文件‘peters-主题/字体/解放-sans-font.css’匹配woff字体类型。
@font-face {
font-family: libertinus-sans;
font-style: normal;
font-weight: normal;
src: url('LibertinusSans-Regular.woff') format('woff');
}
@font-face {
font-family: libertinus-sans;
font-style: italic;
font-weight: normal;
src: url('LibertinusSans-Italic.woff') format('woff');
}
@font-face {
font-family: libertinus-sans;
font-style: normal;
font-weight: bold;
src: url('LibertinusSans-Bold.woff') format('woff');
}woff字体文件位于“peters-主题/字体”目录中。
我希望这些本地字体文件被复制到输出目录..。但这不会发生的。
现在我希望得到一个金提示我做错了什么。
向你问好
彼得
https://stackoverflow.com/questions/65027901
复制相似问题