【问题标题】:`polygon edge not found` with the `xkcd` package`xkcd` 包中的`polygon edge not found`
【发布时间】:2018-07-11 05:38:07
【问题描述】:

我正在尝试使用包“xkcd”制作“xkcd”图。我按照vignette("xkcd-intro") 安装'xkcd'(字体和包)。我只需要添加font_import 的路径,否则会返回错误。

library(extrafont)
download.file("http://simonsoftware.se/other/xkcd.ttf",
  dest="xkcd.ttf", mode="wb")
system("mkdir ~/.fonts")
system("cp xkcd.ttf ~/.fonts")
font_import(path="~/", pattern = "[X/x]kcd", prompt=FALSE)
loadfonts()

我确保字体中列出了“xkcd”

'xkcd' %in% fonts()
TRUE

我安装并导入了包'xkcd'

install.packages('xkcd')
require(xkcd)

我尝试了一个简单的情节

ggplot(mtcars, aes(x=mpg,y=wt)) + geom_point() // works fine


ggplot(mtcars, aes(x=mpg,y=wt)) + geom_point() + theme_xkcd() // Return following error

Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found
In addition: Warning messages:
1: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "xkcd"
2: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "xkcd"
3: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "xkcd"
4: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "xkcd"
5: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "xkcd"

你能帮我解决这个问题吗?


我在 Mac OS X 上

ProductVersion: 10.11.6
BuildVersion:   15G31

【问题讨论】:

    标签: r macos ggplot2 fonts installation


    【解决方案1】:

    我做到了

    fonttable()
    

    找出我的其他字体保存在哪里。他们都保存在/Library/Fonts。所以,我只是把我的 xkcd.ttf 移到了那里

    mv ~/.fonts/xkcd.ttf /Library/Fonts/
    

    我必须更正路径的保存位置。为了找出文件的位置,我做了

    extrafont:::fonttable_file()
    

    然后,我打开了这个文件并更改了xkcd 的路径。有效!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-15
      • 2021-12-27
      • 1970-01-01
      • 1970-01-01
      • 2019-05-12
      • 2019-07-07
      • 2017-10-24
      • 1970-01-01
      相关资源
      最近更新 更多