I moved my largest project onto RStudio Cloud today, hoping I'd be able to use hrbrthemes there (won't work on my Mac). But it doesn't work - and I can't even set the font family in ggplot to "Arial Narrow".
If I do anything to the fonts beside setting a theme (I've been using theme_minimal()), then I get an error.
Here is my plot code, used inside a Rmd document.
speaker_sfvsi %>%
ggplot(aes(x = reorder(speaker, SFVSIspeaker),
y = SFVSIspeaker,
fill = gender)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = pal) +
coord_flip() +
labs(title = "SFVS index by gender") +
theme_minimal() +
theme(text =
element_text(family = "Arial Narrow"))
With the specification of Arial Narrow at the end, it will not work. The error msg. is shown in the attached picture.
The ultimate goal would be to use hrbrthemes. But if I can't have that, I'd be happy simply to be able to specify fonts.
This is all happening inside my project: Posit Cloud
Thank you, Josh. I did take the extrafont steps, and I am now at a point where -- in RStudio Cloud -- I am able to run the plot code chunk on its own. But I can't knit the document (it is a pdf and I am using the tint package, which is an adjusted version of tufte). When I have any font specification at all in my plots, knitr makes it to the relevant plot code chunk and then just stops. Lately it hasn't even given any errors. It just stops processing.
In my local installation of Rstudio, I have had more luck since I have used font specifications - but not hrbrthemes - and those do get knitted. So what works locally is now not working in RStudio Cloud.
It would be nifty if I could run it on Cloud, since rendering is faster there. But at least I've got something working.
When I specify fonts that are listed in the fonts() overview, most of them are displayed in my output PDFs as something else... a serif default font.
When I specify "Arial Narrow" (which I actually want to use) I get an error. This font does not show up when I call fonts(). It's not clear to me how I might install it on RStudio Cloud? When I run the same code locally on the desktop RStudio, it works fine.
You mention installing fonts "into the project" on RStudio Cloud - how would one do that?
A reprex would look as below - keeping in mind that this works fine if run in the GUI - it's the RMD to PDF that doesn't work.
require(tidyverse)
#> Loading required package: tidyverse
dat <- cars
dat %>%
ggplot(aes(x = speed,
y = dist)) +
geom_point() +
theme_light(base_family = "Arial Narrow")
Thanks so much for the example; I came here trying to solve a very similar problem. Unfortunately, the code in that sample doesn't quite solve the problem. I have a custom font I am trying to use, and as far as I can tell I have successfully registered it via ttf_import and font_import. It shows up correctly in the output of fonttable(). However, when I try and use it (via setting the text property of the theme() command to be the same as the FamilyName entry for the font in fonttable()'s output), nothing happens.
This works just fine (i.e., the font text appears in Courier):
I looked at your project and noticed that in your sample doc, fonttable() shows a list that includes Arial Narrow. And it's showing there as coming from cloud/project. So that's cool. After uploading the ttf file to the project folder, what do you have to do to register it with R?
When I run my Rmd in your project, I do get Arial Narrow to show up.
When I run it in my project - where Arial Narrow is not listed by fonttable() - I can't get it to show up or, as a matter of fact, to render the document at all.