8

I'm trying to get a Quarto home page of the ground and one requirement is a custom font (free webfont; Tex-Gyre-Adventor).

Following the documentation, I have played around with the html format specific mainfont tag in various iterations (see header example below), but cannot make this work - including if the font is additionally defined as a @font-face in style.css (and many other attempts).

Can anyone point me in the right direction how to use mainfont with a non-standard font?

Thanks for any pointers!

---
title: "Page"
title-block-banner: false
format:
  html:
    theme: vapor
    mainfont: `https://fontlibrary.org/en/font/tex-gyre-adventor`
    code-fold: true
    toc: false
    number-sections: false
link-citations: yes
---
balin
  • 1,554
  • 1
  • 12
  • 26

1 Answers1

5

To use a custom webfont as the mainfont, just add font stylesheet file in document header using header-includes and set the font name in mainfont yaml key.

---
title: "Page"
title-block-banner: false
format:
  html:
    theme: vapor
    code-fold: true
    toc: false
    number-sections: false
    header-includes: |
      <link rel="stylesheet" media="screen" href="https://fontlibrary.org//face/tex-gyre-adventor" type="text/css"/>
link-citations: yes
mainfont: TeXGyreAdventorRegular
---

## Quarto

Quarto enables you to weave together content and executable code into a
finished document. To learn more about Quarto see <https://quarto.org>.

## Running Code

When you click the **Render** button a document will be generated that
includes both content and the output of embedded code. You can embed 
code like this:

```{r}
1 + 1
```


HTML page with custom webfont


shafee
  • 15,566
  • 3
  • 19
  • 47
  • Thank you for the clear explanation! Is the process very different if one would like to use self-hosted fonts? (I'm thinking of the [IBM Plex](https://github.com/IBM/plex) family.) In that case I'll ask a separate question. Cheers! – pglpm Jul 29 '23 at 18:56
  • 1
    @pglpm, yes AFAIK the CSS part should be different. Probably [this](https://stackoverflow.com/q/75464776/10858321) may be of help in that regard. – shafee Jul 29 '23 at 19:13
  • 1
    Thank you so much! I've actually just discovered that the IBM Plex family is also available on Google fonts, so I can use your answer above! Thank you × 2 – pglpm Jul 29 '23 at 19:17