验证R中的字体可用性
我的操作系统上安装了字体,因此此代码运行良好:验证R中的字体可用性,r,ggtext,R,Ggtext,我的操作系统上安装了字体,因此此代码运行良好: library(tidyverse) library(extrafont) iris %>% ggplot(aes(Sepal.Length,Sepal.Width, color = Species)) + geom_point(size = 2) + theme( text = element_text(family = "Metropolis") ) 让我们强制一个错误注释,我写的是metropolis,而不是metropo
library(tidyverse)
library(extrafont)
iris %>% ggplot(aes(Sepal.Length,Sepal.Width, color = Species)) +
geom_point(size = 2) +
theme(
text = element_text(family = "Metropolis")
)
让我们强制一个错误注释,我写的是metropolis,而不是metropolis:
iris %>% ggplot(aes(Sepal.Length,Sepal.Width, color = Species)) +
geom_point(size = 2) +
theme(
text = element_text(family = "metropolis")
)
这给了我一个错误,这是正常的,因为字体大都市不存在
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
有没有一种方法可以让我在R中验证是否安装了某种字体?提前感谢。您已经在使用extrafont软件包,因此您可以使用字体查看已注册的字体。要检查特定字体是否可用,可以执行以下操作:
library(extrafont)
"metropolis" %in% fonts()
[1] FALSE
您已经在使用extrafont软件包,因此可以使用字体查看已注册的字体。要检查特定字体是否可用,可以执行以下操作:
library(extrafont)
"metropolis" %in% fonts()
[1] FALSE
当我在%fontsit中尝试Metropolis%时,它给了我FALSE。我做错了什么吗?其他字体在可用之前需要在font_import中注册。请参阅了解fontsonly显示ttf字体。现在它起作用了。谢谢。当我在%fontsit中尝试Metropolis%时,它给了我错误的答案。我做错了什么吗?其他字体在可用之前需要在font_import中注册。请参阅了解fontsonly显示ttf字体。现在它起作用了。非常感谢。