所谓的字体的英文名字,应该就是实际的文件名。
x = list.files(file.path(Sys.getenv('SystemRoot'), 'Fonts'))<br />
grep('\\.ttf$', x, ignore.case=TRUE, value=TRUE)<br />
# 结果<br />
# [1] "AGENCYB.TTF" "AGENCYR.TTF" "ALGER.TTF"<br />
# [4] "AndaleMo.TTF" "ANTQUAB.TTF" "ANTQUABI.TTF"<br />
# ....<br />
# [343] "WINGDNG2.TTF" "WINGDNG3.TTF" "ZWAdobeF.TTF"<br />
# [346] "文鼎中隶简.TTF" </p>
<p>## 去掉.ttf就可以了<br />
fontList = sub("\\.ttf", "", grep("\\.ttf$", x, ignore.case = TRUE,<br />
value = TRUE), ignore.case = TRUE)<br />
## 用系统中所有的字体画图<br />
library(Cairo)<br />
n = length(fontList)<br />
CairoPDF(width = 3, height = 3*n)<br />
par(mar = rep(0, 4))<br />
plot(0, xlim = c(0, 2), ylim = c(1, n))<br />
for (i in 1:n) {<br />
text(1, i, paste(fontList[i], "字体"), family = fontList[i])<br />
}<br />
dev.off()<br />
## 见附件<br />
</p>