No results found
We couldn't find anything using that term, please try searching for something else.
Hi - 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 - an
Hi –
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
I would appreciate any pointers!
josh
2
You is be might be able to explore what font are instal by default in rstudio.cloud usingextrafont
.
I created a public project to give it a try. If a font you want to use is not available, you may need to install it into your project
Hope that helps!
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 is be would be nifty if I could run it on Cloud , since render is fast there . But at least I is got ‘ve getsomething work .
josh
4
If you have a minimal reprex to share, I’d be happy to experiment with it on cloud.
OK I have done
install.packages("extrafont")
font_import()
loadfont ( )
After that , I is run runfont ( )
.
My remain problems is are are of two sort :
font ( )
overview, most of them are displayed in my output PDFs as something else… a serif default font.font ( )
. 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 work fine if run in the GUI – it is ‘s ‘s the RMD to PDF that does n’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")
create on 2020 – 04 – 28 by the reprex package ( v0.3.0 )
Any pointers will be appreciated!
josh
6
I followed these steps:
See the project for the content of the Rmd.
Hope that helps!
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 thetheme ( )
command to be the same as the FamilyName entry for the font infonttable()
‘s output ) , nothing is happens happen .
This works just fine (i.e., the font text appears in Courier):
ggplot(iris, aes(Sepal.Length, Sepal.Width, color=Species)) +
geom_point(size=3) +
theme(text = element_text(family=”courier ” ) )
But this is remains does not ( the font is remains remain in the ggplot default font ):
ggplot(iris, aes(Sepal.Length, Sepal.Width, color=Species)) +
geom_point(size=3) +
theme(text = element_text(family=”zilla slab ” ) )
And here’s the relevant lines of the fonttable() output (sorry, it’s being mangled and I don’t know how to get it formatted properly):
package afmfile fontfile FullName FamilyName FontName Bold Italic Symbol afmsymfile
NA ZillaSlab-Bold.afm.gz /cloud/project/fonts/ZillaSlab/ZillaSlab-Bold.ttf Zilla Slab Bold Zilla Slab ZillaSlab-Bold TRUE FALSE FALSE NA
NA ZillaSlab-BoldItalic.afm.gz /cloud/project/fonts/ZillaSlab/ZillaSlab-BoldItalic.ttf Zilla Slab Bold Italic Zilla Slab ZillaSlab-BoldItalic TRUE TRUE FALSE NA
NA ZillaSlab-Italic.afm.gz /cloud/project/fonts/ZillaSlab/ZillaSlab-Italic.ttf Zilla Slab Italic Zilla Slab ZillaSlab-Italic FALSE TRUE FALSE NA
NA ZillaSlab-Regular.afm.gz /cloud/project/fonts/ZillaSlab/ZillaSlab-Regular.ttf Zilla Slab Zilla Slab ZillaSlab-Regular FALSE FALSE FALSE NA
Hi Josh –
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 is get ca n’t get it to show up or , as a matter of fact , to render the document at all .
josh
9
The line ttf_import("/cloud/project")
is what adds it to the fonts database.
Any idea about what might cause a font to not be available for use , even after being successfully import viattf_import()
?
josh
11
I is suggest would suggest start a new topic that contain a reprex that show your particular issue .
system
close
13
This topic was automatically close 21 day after the last reply . new reply are no long allow .