Including fonts from npm in pkgdown

Hi there,

Is there any way to include a font from npm into a pkgdown site? The pkgdown site is hosted on github so I imagine that I could have a github actions runner that installs it and then accesses via extra.css but I am wondering if there are less clunky ways to do it, particularly since that would involve javascript where I have little to no useful knowledge.

Thanks in advance,

Sam

:wave: @boshek!

Could you provide more details on the font files?

I started experimenting with fonts for rotemplate: font test by maelle · Pull Request #65 · ropensci-org/rotemplate · GitHub and actually wondered whether font customization should be better documented in pkgdown Add docs or link to docs of how to specify a non Google font · Issue #1968 · r-lib/pkgdown · GitHub :grin:

Wow ok your approach is way more sensible. I took your approach and applied it here: attempt to add BCSans by boshek · Pull Request #291 · bcgov/bcdata · GitHub

1 Like

I've done some more reading on fonts (and am still not sure I fully understand the topic) and it seems that to load fonts from another domain you need that domain server to set a specific header on the fonts.

I think you store your fonts on GitHub, you might want to serve them from somewhere you have more control (or more easily, from the same domain as the website where you want the font).

Take all of this with a pinch of salt as I'm learning at the same time as you. :grin:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.