2

I'm running code on a new computer (Windows 10 Enterprise OS) with R 4.2.2. I'm running code I've been using for years, but on the new system, my plot shows little white rectangles instead of plotmath symbols.

I've seen several people running into this, with fixes for Mac (here) and Linux (here). Using the cairo option, as proposed here works ok for the exported plots but is extremely slow-rendering for in-console plotting.

I would like to be able to add the missing fonts in, but I can't seem to figure out how to. Here's what I get when I run demo(plotmath).

enter image description here

I seem to only have "Symbol Regular.ttf" font file in my Fonts folder under C\Windows. That is, I don't have a "Symbol.ttf" file. When I open it, there are no multiplication, less-than-or-equal, not equal, etc symbols in it.

enter image description here

Any help would be appreciated!

EDIT This doesn't seem to be a ttf issue, but rather an R issue. Code that works fine on R 4.2.1 doesn't work on R 4.2.2 on the same computer. Toy example below, and a screenshot of the session info and plots are provided. I highlighted the only 2 differences in package versions that I could see. Any help would be appreciated...

library(ggplot2)

df <- data.frame(x = 1:10, y = 11:20, Eq = "WT == 10%*%10^3%*%x^5")
    
ggplot() +
 geom_point(data = df, aes(x = x, y = y)) +
 geom_text(data = df[1,], 
    aes(x = x, y = 20, label = Eq), size = 2.7, parse = TRUE, hjust = 0, show.legend = FALSE)

enter image description here

user2602640
  • 640
  • 6
  • 21
  • It looks like those operators aren't available for Symbol Regular.ttf according to the docs. Two desperate ideas would be 1) to use unicode symbols, which I think is something like '\uxxxx'. 2) You could trick windows by changing the filename of the current Symbol.ttf to something else, and then download a math symbol.ttf and rename it to Symbol.ttf. Sounds really frustrating. – David Jun 13 '23 at 19:11
  • Sorry for the belated response. Turns out the ttf isn't the problem, it's some kind of a change that happened with R 4.2.2. compared to 4.2.1... I would really prefer to have a solution without unicode, just so that I don't have to change all my files to work on the 4.2.2. version... – user2602640 Jul 18 '23 at 13:35
  • Annnnd, apparently fixed in R 4.3.1, which I literally just installed. Sigh. – user2602640 Jul 18 '23 at 13:40

1 Answers1

2

This is an issue with R 4.2.1. It has been fixed in R 4.2.3. You need to update R by installing a new version.

From NEWS:

CHANGES IN R 4.2.3

BUG FIXES:

(Windows) Math symbols in text drawing functions are again rendered correctly (PR#18440). This fixes a regression in R 4.2.1 caused by a fix in PR#18382 which uncovered an issue in GraphApp due to which the symbol charset was not used with TT Symbol font face.

jan-glx
  • 7,611
  • 2
  • 43
  • 63
  • Yeah, I figured it out 5 minutes after posting the bounty, lol. Thank you for posting an answer, I'll award the bounty once the system allows me to. – user2602640 Jul 18 '23 at 14:58