我正在寻找帮助,使用strwidth
以英寸为单位测量字符串的宽度。我应该如何指定字体和字体大小?(例如,Times New Roman 中的"ABC%"或"ABIi%"和字体大小 11(
strwidth("ABC%", family="Times New Roman", units="inches")
strwidth("ABIi%", family="Times New Roman", units="inches")
我认为您的问题源于R
无法识别字体。假设您在 Windows 机器上,请按如下方式初始化您的字体。然后运行strwidth
.
windowsFonts("Times New Roman" = windowsFont("Times New Roman")) #initialize font first
strwidth("ABC%", family = "Times New Roman", units = "inches")
[1] 0.46875