我试图导入字体为GGPLOT2图中所描述这里。
当我尝试使用此代码逐个执行此操作时:
font_import(pattern = "Arial.ttf")
y
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
canning ttf files in C:\windows\Fonts ...
Extracting .afm files from .ttf files...
Error in data.frame(fontfile = ttfiles, FontName = "", stringsAsFactors = FALSE) :
arguments imply differing number of rows: 0, 1
Run Code Online (Sandbox Code Playgroud)
我的问题是什么
小智 5
我遇到了同样的问题,即尝试使用font_import()并收到相同的错误来导入字体(Zallman Caps):
"Error in data.frame(fontfile = ttfiles, FontName = "", stringsAsFactors = FALSE) :
arguments imply differing number of rows: 0, 1"
Run Code Online (Sandbox Code Playgroud)
经过大量的反复试验,我终于找到了一个对我有用的解决方案,也许对你也有用。
尽管我可以在我的 Windows 字体文件夹中看到 Zallman Caps 字体并验证它在 Word 中工作,但在那里既找不到font_import()也list.files()找不到它。我设法通过输入以下代码导入字体:
font_import(path = "C:/Users/*insert your user name*/AppData/Local/Microsoft/Windows/Fonts", pattern = ".TTF")
Run Code Online (Sandbox Code Playgroud)
我不知道为什么它在主字体目录中对 R 不可见,当我可以在 Windows 文件资源管理器中清楚地看到它时,但至少我设法使用此解决方法导入了字体。