Custom font in RStudio Server?

rstudio-server

#1

I'd love to play with the new ligature support in RStudio Server, but I don't see an option to change editor fonts at all in 1.1.383. Is there a hidden setting for font changes?


#2

I don't believe that the server version of RStudio allows for native font customization. There's an old support question about that:

And I haven't found any indication that it has changed since then. You may be able to do something with custom CSS, but I haven't dug into that at all.


#3

Re: "You may be able to do something with custom CSS" -- I've come up with the following CSS:

pre, .ace_text-layer, .xterm-rows, tr[data-entry-id], td[__gwt_cell] {
  font-family: "Source Code Pro", monospace !important;
}

Obviously, substitute the font you want for Source Code Pro. It's not very clean, unfortunately, there's no single way to identify all of the places where monospace font is used. This is the best I've come up with so far, it affects the code editor, the console, the terminal, the code samples in the Help tab, and the Environment and History tabs.

The easiest way to inject this CSS into the RStudio page is using an addon like Stylish. If you're already using a userscript manager like Greasemonkey and would rather not install another addon, you can inject the CSS with a usercript along the following lines:

// ==UserScript==
// @version         ∞
// @name            RStudioMonoFont
// @namespace       https://github.com/dlukes
// @author          dlukes
// @description     Change RStudio Server monospace font.
// @match           *://YOUR.RSTUDIO-SERVER.URL
// @run-at          document-end
// ==/UserScript==
(function () {
  var style = `
pre, .ace_text-layer, .xterm-rows, tr[data-entry-id], td[__gwt_cell] {
  font-family: "Source Code Pro", monospace !important;
}
  `;
  var styleNode = document.createElement("style");
  styleNode.appendChild(document.createTextNode(style));
  document.body.appendChild(styleNode);
})();

#4

I tried this out but it causes the cursor to be placed at the wrong location which is very distracting. However, changing the monospaced font in latest version of google chrome works fine


#5

We have an open request for this -- feel free to comment (and please upvote if it's important to you):

RStudio Server can't see what fonts you have installed on your system without unpleasant hackery so it doesn't currently try.


closed #6

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.