s-u / Cairo

R graphics device using cairo graphics library for creating high-quality output
12 stars 10 forks source link

is there a problem rendering math greeks? #46

Open rafalcode opened 8 months ago

rafalcode commented 8 months ago

your typical beta for example .. let's try non Cairo pdf

pdf("dev20.pdf")
plot(1:20)
text(x=1,y=15, bquote(beta=="5"))
dev.off()

that's fine, but with R's Cairo

CairoPNG("dev20.png", 800, 800)
plot(1:20)
text(x=1,y=15, bquote(beta=="5"))
dev.off()

for the beta there is nothing. Otherwise, my installation of R Cairo works fine. I'm on Debian bookworm R-4.3.2, package ver Cairo_1.6-2. Thanks!

s-u commented 8 months ago

This typically means that the font you're using doesn't have the necessary characters - check out https://github.com/s-u/Cairo/issues/25 to see if it helps. Short story is that you may need to use Cairo::CairoFonts() to select the font that has symbols on your system since the default one apparently doesn't have it.

rafalcode commented 8 months ago

oh right ... that's embarrassing I worked on a cairo-pango project back in '21 .. I should have guessed that. Thank you!

rafalcode commented 8 months ago

that said, fonts can be tricky ... I found that changing the font to "Standard Symbols PS" the regular text came out in greek script .. but the bquote symbol still didn't show. So I just went for a workaround, directly input the beta symbol into the raw R code. That won't work for everybody, but I got out of jail on it.