Ligatures in RStudio 1.1.364 preview

I'm trying out the new support for fonts with code ligatures in 1.1.364, and it looks great! Here's Fira Code:

It's a small change but really does make the code more readable. But (sadface) it seems that Fira Code doesn't support some R tokens that really ought to be ligatured, like %>% pipes and %in% operators. Are there fonts that support these?

2 Likes

Do you have any examples of what those would look like? I know there's an open request re. the pipe operator in FiraCode, and I've been exploring a few others, but I'm not sure what to look out for. I think %in% is helpful to see, but that's just IMHO, and I don't know what it would look like!

Ah, someone has already requested it -- thanks for point me to that. As for what the ligature would look like, I'm no typeface designer but I'd like to emphasize the arrow > part and de-emphasize the ugly percent signs. I'm imagining a prominent right bracket > or arrowhead with small dots or bars, like />/ or •►• . Or maybe little bitty Magritte pipes?

3 Likes

Few more options using common mathematical signs
image

2 Likes

In all logic x %in% y could be
image

But purists might object...

2 Likes

Also
image
might be a good candidate for data.table assignment by reference := sign.

Screenshot with some more:

<-
[[ and ]]
%in%
%>%
::
:::

It would be great to have them in nice font.

5 Likes

In a similar vayne a function could be defined with ƒ(…)

1 Like

the ligature for %>% shown here seems problematic. that kind of arrow (\Rightarrow in LaTeX) has always meant "implies" to me, so I see that line as 1:10 implies mean. Something more like the %in% ligature would be more clear to me.

2 Likes

Hasklig is also a nice ligature font, btw - I prefer it over Fira Code, give it a try. It has the same problem, though - no ligatures for %>% et al

What font size/theme do you use? With my standard settings -- 11 pt font, Cobalt (dark) theme, on a non-retina display, I couldn't find a Hasklig variant that was better than mediocre. Fira Code looked much better, so I didn't dig very far into it.

It's Hasklig-Regular 9pt, Solarized Dark theme - on a Mac though, with a retina display. Gorgeous! The real reason I chose Hasklig over Fira Code was something else, however, I just can't remember why :grin: I'd have to compare them side by side again.

1 Like

I figured that a high DPI display would help Hasklig. This is what it looked like on my setup:
Hasklig

Each variant would fix some problems but also cause new ones. Fira Code "just worked":
Fira Code

I see your point - weird! Is this on Windows? This is what it looks like on my machine. I read somewhere that there are known font rendering issues on Windows, particularly on high-DPI displays (similarly on Linux). Not sure :slightly_frowning_face:

Yes, Windows 7. Even increasing the font size still gives much less sharp results than yours; it may be an issue with ClearType.

It looks much improved on a Windows 10 high DPI laptop (hidden for image size). I'll take a look at it on a standard resolution Windows 10 PC at some point; I seem to remember Windows 7 and earlier having some issues with anti-aliasing text under "certain" circumstances (that I can't recall at the moment).

Image

Btw. can anyone tell me how hard it would be to put some of the R ligatures into Fira Code, or some other open source font? Assuming the license allows this, of course.

It feels to me that it should not be too hard, as they don't really need new designs, just modifying or combining the existing glyphs and getting the spacing around them right.

But I know next to nothing about fonts...