Add copy-custom-fonts parameter to HtmlConfig to enable custom fonts #1807
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The first PR #1799 has been accidentially closed.
This PR introduces a new parameter to the
HtmlConfig
struct namedcopy_custom_fonts
. When set to true, the fonts/fonts.css file is scanned for @font-face rules that contain a src: url(font-file.name) attribute. The files that have been found are copied into the book folder on build/serve.If
copy_fonts
is also enabled, the build infonts/fonts.css
is extended by the custom one. In addition to that, the build in font files are also copied to the output folder.Example usage:
Create a
fonts/
folder in your book root. Then copy the fonts you want to use into this folder (in this example we are assumingLato-Regular.ttf
)Create a custom fonts file
fonts/fonts.css
Setup your
book.toml
that it contains the following parameters:Adjust your
theme/css/general.css
file according to your needs, for example:It adds a new dependency
lewp-css
toCargo.toml
for simple parsing of thefonts/fonts.css
file.It also updates the
msrv
to1.56.0
becauselewp-css
requires edition 2021.Furthermore, the
clap
dependency gets updated.