r - 我无法使用 font_import 导入字体
问题描述
我正在尝试为 ggplot2 图形导入字体,如此处所述。
当我尝试使用此代码逐步完成时:
font_import(pattern = "Arial.ttf")
y
我收到此错误:
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
我的问题是什么
解决方案
我遇到了同样的问题,即尝试使用font_import()
并接收相同的错误导入字体(Zallman Caps):
"Error in data.frame(fontfile = ttfiles, FontName = "", stringsAsFactors = FALSE) :
arguments imply differing number of rows: 0, 1"
经过大量的反复试验,我终于找到了一个对我有用的解决方案,也许它也对你有用。
尽管我可以在我的 Windows 字体文件夹中看到 Zallman Caps 字体并验证它在 Word 中有效,但在那里font_import()
也list.files()
找不到它。我设法通过输入以下代码导入字体:
font_import(path = "C:/Users/*insert your user name*/AppData/Local/Microsoft/Windows/Fonts", pattern = ".TTF")
当我可以在 Windows 文件资源管理器中清楚地看到它时,我不知道为什么它在主字体目录中对 R 不可见,但至少我设法使用此解决方法导入了字体。
推荐阅读
- swift - 表单值更新时使用 Combine + SwiftUI 来更新值
- python - OpenCV视频播放:重新打开视频时不显示图像
- vue.js - 属性或方法“item”未在实例上定义,但在渲染期间引用
- node.js - 错误:尝试启动应用程序时找不到模块“commander”
- python - psycopg2 为 json_agg 返回单引号而不是双引号
- sparql - Wikidata 查询服务为实体搜索返回空
- sql-server - 将 MSSQL 数据库与 docker 连接
- laravel - 型号 [App\Models\Customer] 背包没有查询结果
- r - 如何根据R中的字符向量从df中提取部分字符串
- sql-server - 无法修复 sql 查询中的语法错误