首页 > 解决方案 > R中的pdffonts中的额外字体

问题描述

运行名称时列出了以下字体(pdfFonts())

> names(pdfFonts())
 [1] "serif"                   "sans"                    "mono"                    "AvantGarde"              "Bookman"                
 [6] "Courier"                 "Helvetica"               "Helvetica-Narrow"        "NewCenturySchoolbook"    "Palatino"               
[11] "Times"                   "URWGothic"               "URWBookman"              "NimbusMon"               "NimbusSan"              
[16] "URWHelvetica"            "NimbusSanCond"           "CenturySch"              "URWPalladio"             "NimbusRom"              
[21] "URWTimes"                "ArialMT"                 "Japan1"                  "Japan1HeiMin"            "Japan1GothicBBB"        
[26] "Japan1Ryumin"            "Korea1"                  "Korea1deb"               "CNS1"                    "GB1"                    
[31] ".Keyboard"               "Andale Mono"             "AppleMyungjo"            "Arial Black"             "Arial Narrow"           
[36] "Arial Rounded MT Bold"   "Arial Unicode MS"        "Batang"                  "Bodoni Ornaments"        "Bodoni 72 Smallcaps"    
[41] "Bookshelf Symbol 7"      "Calibri"                 "Cambria"                 "Cambria Math"            "Candara"                
[46] "Comic Sans MS"           "Consolas"                "Constantia"              "Corbel"                  "Courier New"            
[51] "Franklin Gothic Book"    "Franklin Gothic Medium"  "Gabriola"                "Georgia"                 "Gill Sans MT"           
[56] "Gulim"                   "Impact"                  "Khmer Sangam MN"         "Lao Sangam MN"           "Lucida Console"         
[61] "Lucida Sans Unicode"     "Luminari"                "Marlett"                 "Meiryo"                  "Microsoft Yi Baiti"     
[66] "Microsoft Himalaya"      "Microsoft Sans Serif"    "Microsoft Tai Le"        "MingLiU_HKSCS-ExtB"      "MingLiU_HKSCS"          
[71] "MingLiU"                 "MingLiU-ExtB"            "Mongolian Baiti"         "MS Gothic"               "MS Mincho"              
[76] "MS PGothic"              "MS PMincho"              "MS Reference Sans Serif" "MS Reference Specialty"  "Palatino Linotype"      
[81] "Perpetua"                "PMingLiU"                "PMingLiU-ExtB"           "SimHei"                  "SimSun"                 
[86] "SimSun-ExtB"             "Tahoma"                  "Trattatello"             "Trebuchet MS"            "Tw Cen MT"              
[91] "Webdings"    

我想在 R 中写入 pdf 文件时使用“Verdana”。

我正在使用以下命令为 pdf 指定字体

pdf("abc.pdf",height = 11, width = 8.5,family = "Helvetica")

我电脑上的字体包括 Verdana

fonts()
[66] "Trattatello"             "Trebuchet MS"            "Tw Cen MT"               "Verdana"                 "Webdings"               
[71] "Wingdings"               "Wingdings 2"             "Wingdings 3"            

标签: rpdffonts

解决方案


问题是因为 R 的安装检测到 Verdana Bold/Italic 的重复字体,并且当我load_fonts()从 extrafonts 包运行时跳过将 Verdana 添加到 pdffonts

所以我从我的电脑中删除了所有 Verdana 字体并重新安装了它们。然后按照自述文件中的步骤获取 extrafonts 包并解决了问题


推荐阅读