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:
- I got the .ttf file(s) for the font and installed them on Windows. I can actually access it now in Word, so that part worked.
- I edited the YAML part pf my rmarkdown file to reference the font. When I try this with fonts native to Windows (Arial, etc.) this works, so in general the code itself should not be wrong.
EDIT: I found that it also does not work for some of the pre-installed windows fonts, like Bahnschrift (which might be german-specific)
- I tried on 2 different PCs and both with lualatex and xelalatex. As described below I also tried extrafont for the plots and it doesnt recognize the font either.
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.