Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install new font in RStudio?

I want to install a new font in RStudio. More specifically, I use RStudio in my office (Windows) and at home (OS X), but I see that the fonts are different and takes me a while to get used to that.

Can someone suggest how to install SAS monospace font in RStudio in Mac?
(I did a search here and in Google but I had no luck finding an answer to my question.)

Thank you in advance!

like image 461
klo Avatar asked Aug 26 '14 18:08

klo


People also ask

How do I change the font in RStudio?

Go to the menu in RStudio and click on Tools and then Global Options. Select the Appearance tab on the left. Again buried in the middle of things is the font size. Change this to 14 or 16 to start with and see what it looks like.

Where does R Look for fonts?

Usually the font files are located in some “standard” directories in the system (for example on Windows it is typically C:\Windows\Fonts ). You can use font_paths() to check the current search path or add a new one, and use font_files() to list available font files in the search path.


1 Answers

I ran into similar issue on Windows I wanted to use a new font I installed, mononoki font. I could not find an option to change so I look at RStudio source code and discovered that for Desktop Version of RStudio, RStudio automatically loads fonts from the OS. It should work the same way on MAC.

All you have to do is:

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!)

Here is the code which loads the fonts from RStudio. As you can see it automatically loads proportional and fixed fonts. The Web Version of RStudio restricts the font selection to only a few fonts.

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

      public native final String getFixedWidthFont() /*-{
         return $wnd.desktop.fixedWidthFont();
      }-*/;
   }
like image 89
KK. Avatar answered Oct 02 '22 17:10

KK.