如何在RStudio中安装新字体?

时间:2014-08-26 18:06:01

标签: macos fonts rstudio

我想在RStudio中安装一个新字体。 更具体地说,我在我的办公室(Windows)和家里(OS X)使用RStudio,但我发现字体不同,需要一段时间才能适应它。

有人可以建议如何在Mac中的RStudio中安装SAS monospace字体吗?
(我在这里和谷歌进行了搜索,但我没有找到答案回答我的问题。)

提前谢谢!

1 个答案:

答案 0 :(得分:3)

我在Windows上遇到了类似的问题我想使用我安装的新字体mononoki字体。我找不到更改的选项,所以我查看RStudio源代码,发现对于RStudio的桌面版,RStudio会自动从操作系统加载字体。它应该在MAC上以相同的方式工作。

您所要做的就是:

1.Install your font as usual for your OS
2.Then restart RStudio
3.The new font appears in the Editor Fonts pull down menu 
   (navigation: Global Options -->Appearance --> Editor Fonts)
4.Select the font from Editor Fonts pulldown menu.(Your Done!)

这是加载来自RStudio的字体的code。如您所见,它会自动加载比例和固定字体。 RStudio的Web版本将字体选择限制为仅几种字体。

 static class DesktopThemeFontLoader implements ThemeFontLoader
   {
      public native final String getProportionalFont() /*-{
         return $wnd.desktop.proportionalFont();
      }-*/;

      public native final String getFixedWidthFont() /*-{
         return $wnd.desktop.fixedWidthFont();
      }-*/;
   }