use font in base graphics legend()?
jxchong opened this issue · comments
Thanks for this package. I was able to get a font loaded and use the family="" argument to select my font when I use the mtext and text commands, however if I try to use the font with legend(), I get an error
> legend("topleft", fill=mycolors, legend=modelnames, border=NA, bty="n", cex=0.8, family="Myriad Pro")
Error in legend("topleft", fill = morecolors, legend = modelnames, border = NA, :
unused argument (family = "Myriad Pro")
You can call par(familly = "")
before drawing the legend, see https://stackoverflow.com/a/7137354.
Ah got it thanks. Is there any way to load the font into the PostScript font database too? It works if I draw directly to a plotting window, but if I try to use pdf(xxx) to plot to a file, I get the error font family 'Myriad Pro' not found in PostScript font database
Did you correctly load the showtext
package and call showtext_auto()
? showtext
is the package you directly use, and sysfonts
is just a backend. You can take a look at the example of showtext
here.
Ah I see, thank you. I misunderstood and thought showtext was only if I wanted to render the text to polygons. I'm hoping to embed the fonts in the PDF and keep it as text so it can be edited in other programs.
In this case showtext
is not the proper tool. You may consider using extrafont instead.