rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.84k stars 1.62k forks source link

Cannot load custom font files with 'mdbook serve' on macOS #2405

Closed b1nhack closed 3 months ago

b1nhack commented 3 months ago

Problem

On macOS, custom font files fail to load when previewing the page, while testing the same source files on Windows shows the fonts loading correctly.

Steps

  1. Place the font files into theme/fonts/
  2. Create a theme/fonts/fonts.css file and paste the following content:
    
    /* JetBrains Mono is licensed under the SIL Open Font License 1.1 */

@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: normal; font-display: swap; src: url("JetBrainsMono-Regular.woff2") format("woff2"); }

@font-face { font-family: "JetBrains Mono"; font-style: italic; font-weight: normal; font-display: swap; src: url("JetBrainsMono-Italic.woff2") format("woff2"); }

body { font-family: "JetBrains Mono", monospace; font-size: 2.5em; line-height: 1.2; }

3. mdbook serve --open

### Possible Solution(s)

_No response_

### Notes

_No response_

### Version

```text
mdbook v0.4.40