I have a font installed on my OS, so this code runs fine:
library(tidyverse)
library(extrafont)
iris %>% ggplot(aes(Sepal.Length,Sepal.Width, color = Species)) +
geom_point(size = 2) +
theme(
text = element_text(family = "Metropolis")
)
Let's force an error (note that I wrote "metropolis", not "Metropolis"):
iris %>% ggplot(aes(Sepal.Length,Sepal.Width, color = Species)) +
geom_point(size = 2) +
theme(
text = element_text(family = "metropolis")
)
That gives me an error, which is ok because font "metropolis" doesn't exist.
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
Is there a way where I can verify before if certain font is installed, in R? Thank you in advance.