Reputation: 316
I am building a map in R that I would like to have the text to be shown in Linux Libertine font. Package extrafont
is loaded, fonts have been loaded and the path to ghostscript is correctly set.
When I use the following command, R saves the output and everything works fine.
ggsave(file = foo.eps, plot = map, width = 15, height = 10, units = "cm", family='Linux Libertine Display')
However when I instead use family='Linux Libertine'
, I receive the following error message:
Error in grDevices::postscript(..., onefile = FALSE, horizontal = FALSE, :
unknown family 'Linux Libertine'
It seems that it can't find the font, which is weird as it is listed in the return of fonttable()
. Any ideas how I can make R to use the font?
Upvotes: 1
Views: 725
Reputation: 316
The link provided by user TomNash does indeed explain the problem and the solution:
The problem is that some fonts (and this includes Linux Libertine) have distinct font face names (Linux Libertine Bold, Linux Libertine Italics, etc.) but all share the same family name (Linux Libertine). The extrafont
package cannot distinguish between those fonts, because it only looks at the family name (and in the above example Linux Libertine Display works, because this is a unique family name).
The easiest way to fix this is to locate the directory of the font table: system.file("fontmap", "fonttable.csv", package="extrafontdb")
and then open the fonttable.csv
and copy for all Linux Libertine fonts (or whatever fonts this concerns) the font name into the font family cell. Then return to R and execute loadfonts()
again to make sure R rebuilds the font table.
Upvotes: 2