【发布时间】:2021-02-04 06:49:07
【问题描述】:
我在让 Fontawesome5 在 R 中工作时遇到问题。我安装了最新版本的 R,因此所有使用的包都更新了,我无法让字体在 R 中工作。它用于制作信息图形,请参阅此处的网站:https://www.listendata.com/2019/06/create-infographics-with-r.html
一旦我上传了 ttf.文件到 R 我收到此错误消息: 在 grid.Call.graphics(C_text, as.graphicsAnnot(x$label), ... 中: 未找到字体系列“FontAwesome5Free-Solid”,将改用“wqy-microhei”
这意味着我得到了一个没有字体的情节,只有一个点。 (见图)【R图不带字体1
看起来 R 不能将 Fontawesome5(第 5 版)放到 ggplot2/pdf 上。有没有办法让这个字体在 R 中与 ggplot 一起工作?James 说。
library(ggplot2)
library(waffle)
library(extrafont)
library(tidyverse)
library(echarts4r)
library(echarts4r.assets)
install.packages("extrafontdb", repos = "http://cran.rstudio.com/")
library(extrafont)
#font download: https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/fonts/fontawesome-webfont.ttf
extrafont::font_import (path="C:/file/location/Documents/R", pattern = "awesome", prompt = FALSE)
install_fa_fonts()
extrafont::font_import (path="C:/Users/User/Documents/R/win-library/4.0/waffle/fonts") #path is where R installs file:
loadfonts(device = "win") #loads in fonts
fonts()[grep("Awesome", fonts())] # should say Awesome fonts 5 in installed.
waffle(
c(`Poor=10` =10, `Average=18` = 18, `Excellent=7` =7), rows = 5, colors = c("#FD6F6F", "#93FB98", "#D5D9DD"),
use_glyph = "female", glyph_size = 12 ,title = 'Girls Performance', legend_pos="bottom"
)
【问题讨论】:
-
我遇到了同样的问题,经过数周的研究仍未找到解决方案。它发生在我的 Mac OS 更新到 Catalina 之后。