I have an rmarkdown file for which I want to change the font to a custom font (not native to Windows). What I did so far:
EDIT: I found that it also does not work for some of the pre-installed windows fonts, like Bahnschrift (which might be german-specific)
Here YAML code: the rest of the rmarkdown is really just the unchanged template. Round Style is just an example.
---
title: "Untitled"
author: "Someone"
date: "7/8/2021"
output:
pdf_document:
latex_engine: lualatex
mainfont: Round Style
---
#==EDIT====
or another version:
---
title: "Untitled"
author: "Someone"
date: "7/8/2021"
output:
pdf_document:
latex_engine: lualatex
\usepackage{fontspec}
---
\setmainfont{Round Style}
#==EDIT=END====
My suspicion is that R just doen't realize that the font is installed. When I try find the font via the extrafont package using first font_import() and then fonts() the list that it shows does not contain the new font.
Any help would be great. There are many results for custom fonts but I didn't see this particular issue tackled.
The main error I get is:
! fontspec error: "font-not-found"
!
! The font "RoundStyle" cannot be found.
The line header-includes: is missing. Try with the following header:
---
title: "Untitled"
author: "Someone"
date: "7/8/2021"
output:
pdf_document:
latex_engine: lualatex
header-includes:
- \usepackage{fontspec}
---
\setmainfont{Round Style}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With