Previously, I was able to make alterations to the ggplot2 font by using the code mentioned below:-
windowsFonts(Times=windowsFont("TT Times New Roman")).
But regardless of this, I am now not able to get it off this due to the reason that while trying to set the family="" in ggplot2 theme(), the change of fonts generation is not successful. I am trying to compile the MWE shown below with various font families.
library(ggplot2) library(extrafont) loadfonts(device = "win") a <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + ggtitle("Fuel Efficiency of 32 Cars") + xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") + theme(text=element_text(size=16, # family="Comic Sans MS")) # family="CM Roman")) # family="TT Times New Roman")) # family="Sans")) family="Serif")) print(a) print("Graph should have refreshed")
I observed that when the R returns a warning, if the Windows font database does not show the font family as results, then this is a normal step and is not a problem. Due to the graph using an arial type font, enabled it to work at one time Therefore, this has always been a present warning even during the initial times migration.
UPDATE
when I run windowsFonts() my output is
$serif [1] "TT Times New Roman"
$sans [1] "TT Arial"
$mono [1] "TT Courier New"
If this is after you have run font_import() then I can only conclude that your fonts are not being saved in the right place. The code that ran the font_import() request actually loads the libraries with:
LocalLibraryLocation <- paste0("C:\\Users\\",Sys.getenv("USERNAME"),"\\Documents","\\R\\win-library\\3.2"); .libPaths(c(LocalLibraryLocation, .libPaths()))