EeethB
December 4, 2020, 9:23pm
1
Related to these 3:
I am trying to install Fira Code (a new font) onto RStudio, but am unable - the font does not appear in the drop-down list after installation to my computer. Tried on Windows 10 and it works fine.
Hi all-
my PC:
Ubuntu 20.04.4,
R 4.0
and Rstudio 1.3.1056 (latest).
Installed FiraCode font ok:
$ sudo apt install fonts-firacode
It shows up as a font in other progs
(ie: Libre Writer),
but not in Rstudio...
The Ubuntu "Font Mgr" prog
also shows FiraCode font ok.
Problem:
FiraCode font
does not show up as an option
in Rstudio
Global Options / Appearance / Editor font dropdown menu...
The FiraCode *.otf files are in folder:
/usr/share/fonts/opentype/firacode/
Can somebody please help!.
sfdude
I recently installed some new monospace fonts (e.g. Fira Code, JetBrains Mono) to my computer (Ubuntu) and when I go to global options in RStudio the new fonts don't appear for selection, even after a restart of RStudio and my computer.
I've installed Firacode using every method I can find, but RStudio can't detect it (It's not available in Tools -> Global Options -> Appearance). I've tried all the fixes in the three links above, but nothing has worked. I've restarted RStudio and my computer. fc-list | grep "fira"
returns the path to several OTF files in /usr/share/fonts/opentype/firacode
Any help is greatly appreciated! I'm working on reading through the RStudio source code to see where fonts are loaded, but I don't know java, so it's been slow. If anyone has found another way to get this to work, I would love to hear it!
What worked for me with the JetBrains Mono font (also couldn't get it to work) is that I installed a different version of it that didn't include ligatures and then RStudio detected it with no problem.
1 Like
EeethB
December 4, 2020, 10:22pm
3
Thanks for the response! I'm mainly trying it out to see how I like the ligatures, so I'm really hoping to find a solution that keeps them. But I do like the font itself, so maybe I will still try it out. Thanks again!
Do you also see this issue with the current preview release ?
If so, would you mind filing this as a bug report at https://github.com/rstudio/rstudio/issues , so we can try to investigate further?
1 Like
For extra context, this is where we build the list of fonts to be used by RStudio:
if (desktop::options().useFontConfigDatabase())
{
// if fontconfig is installed, we can use it to query monospace
// fonts using its own cache (and it should be much more performant
// than asking Qt to build the font database on demand)
core::system::ProcessOptions options;
core::system::ProcessResult result;
Error error = core::system::runCommand(
"fc-list :spacing=100 -f '%{family}\n' | cut -d ',' -f 1 | sort | uniq",
options,
&result);
bool didReturnFonts =
!error &&
result.exitStatus == EXIT_SUCCESS &&
!result.stdOut.empty();
if (didReturnFonts)
{
s_fixedWidthFontList = QString::fromStdString(result.stdOut);
This file has been truncated. show original
So, the output of the following would likely be helpful:
fc-list :spacing=100 -f '%{family}\n' | cut -d ',' -f 1 | sort | uniq
1 Like
EeethB
December 10, 2020, 5:57am
6
Thank you, Kevin! I appreciate the context, and I will check the preview release and file the issue.
$ fc-list :spacing=100 -f '%{family}\n' | cut -d ',' -f 1 | sort | uniq
Courier 10 Pitch
DejaVu Sans Mono
FreeMono
Hasklig
Liberation Mono
Mitra Mono
Nimbus Mono PS
Noto Color Emoji
Noto Mono
Tlwg Mono
Tlwg Typo
Ubuntu Mono
EeethB
December 11, 2020, 9:38am
7
While working on filing this issue, I actually found this one:
opened 02:15PM - 16 May 20 UTC
closed 12:25AM - 26 Feb 21 UTC
enhancement
desktop integration
### System details
RStudio Edition : Desktop
RStudio Version : 1.3.959 ([U… buntu 18/Debian 10 package](https://download1.rstudio.org/desktop/bionic/amd64/rstudio-1.3.959-amd64.deb))
OS Version : Linux (Ubuntu 20.04)
R Version : 4.0.0
### Steps to reproduce the problem
1. Install RStudio.
2. [Install Fira Code](https://github.com/tonsky/FiraCode/wiki/Installing), either [manually](https://github.com/tonsky/FiraCode/wiki/Linux-instructions#manual-installation) or by issuing
```sh
sudo apt install fonts-firacode
```
3. Open RStudio, go to <kbd>Tools</kbd>→<kbd>Global Options...</kbd>→<kbd>Appearance</kbd> and try to select `Fira Code` as _Editor font_ (it doesn't show up!).
### Describe the problem in detail
RStudio detects available monospace fonts on Linux using this command:
https://github.com/rstudio/rstudio/blob/30aa1f83a276c19fb2212e562b436b0086fa4ef2/src/cpp/desktop/DesktopInfo.cpp#L117
<sub>(`fc-list :spacing=100` is equivalent to `fc-list :spacing=mono` or just `fc-list :mono`)</sub>
The problem is, that there are also so called "dual-width" and "charcell" (i.e. multiple-width) fonts (recent versions of [Fira Code](https://github.com/tonsky/FiraCode/) or [Terminus](http://terminus-font.sourceforge.net/) for example) which are **not** listed by the `:spacing=100` option **but** `:spacing=90` (or the equivalent `:spacing=dual` or just `:dual`) and `:spacing=110` (or the equivalent `:spacing=charcell` or just `:charcell`).
Possible `spacing` values in fontconfig are described [here](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html):
Constant | Property | Value
-------- | -------- | -----
proportional | spacing | 0
dual | spacing | 90
mono | spacing | 100
charcell | spacing | 110
Imortant in this context:
> [spacing is not set by the font. Spacing is calculated from actual glyph
sizes in the font file by fontconfig](https://github.com/kovidgoyal/kitty/issues/1968#issuecomment-531437076)
### Describe the behavior you expected
I expected dual-width fonts like Fira Code and charcell fonts like Terminus to show up by default in RStudio.
### Solution
I think the proper way to support dual-width and charcell fonts would be to change [line 117 of `src/cpp/desktop/DesktopInfo.cpp`](https://github.com/rstudio/rstudio/blob/master/src/cpp/desktop/DesktopInfo.cpp#L117) to something like:
```sh
"{ fc-list :mono -f '%{family}\n' & fc-list :dual -f '%{family}\n' & fc-list :charcell -f '%{family}\n'; } | cut -d ',' -f 1 | sort | uniq",
```
### Workaround
For now, a possible ("hackish") workaround is to [overwrite the `spacing` of the desired font to `100` (`mono`) using a custom fontconfig `.conf` file](https://github.com/tonsky/FiraCode/issues/840#issuecomment-531471498).
### See also
- https://github.com/rstudio/rstudio/issues/3862
- https://github.com/rstudio/rstudio/issues/3909
- [Rethinking the spacing detection: Dual Width => Multiple width](https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/176)
---
<!--
Please keep the below portion in your issue, and check `[x]` the applicable boxes.
-->
- [x] I have read the guide to submitting good bug reports at https://github.com/rstudio/rstudio/wiki/Writing-Good-Bug-Reports .
- [x] I have installed the latest version of RStudio and confirmed that the issue still persists.
- [x] If I am reporting a RStudio crash, I have included a diagnostics report. https://support.rstudio.com/hc/en-us/articles/200321257-Running-a-Diagnostics-Report
- [x] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
It looks like Fira Code is being filtered out by the :spacing=100
step.
$ fc-list :spacing=90 -f '%{family}\n' | cut -d ',' -f 1 | sort | uniq
Fira Code
system
Closed
January 1, 2021, 9:38am
8
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.