Allow Custom fonts for R outputs
complete
T
Teal Impala
In our local R programs, we use the Onest font for our plots. We're trying to import the fonts into DisplayR R Outputs, but it doesn't work for these custom R outputs. The user would like to be able to use a similar method to https://help.displayr.com/hc/en-us/articles/4414061615631-How-to-Use-Custom-Fonts-in-Displayr, but have it work on R outputs.
J
Jamie Morris
marked this post as
complete
This is possible using the showtext library. Example R code:
Example from https://cran.r-project.org/web/packages/showtext/vignettes/introduction.html
require("showtext")
font_add_google("Gochi Hand", "gochi")
font_add_google("Schoolbell", "bell")
## Automatically use showtext to render text
showtext_auto()
set.seed(123)
hist(rnorm(1000), breaks = 30, col = "steelblue", border = "white",
main = "", xlab = "", ylab = "")
title("Histogram of Normal Random Numbers", family = "bell", cex.main = 2)
title(ylab = "Frequency", family = "gochi", cex.lab = 2)
text(2, 70, "N = 1000", family = "bell", cex = 2.5)