Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode text fails after attaching ragg #35

Open
StefanoMezzini opened this issue Sep 29, 2022 · 12 comments
Open

Unicode text fails after attaching ragg #35

StefanoMezzini opened this issue Sep 29, 2022 · 12 comments

Comments

@StefanoMezzini
Copy link

Attaching the ragg package prevents one from using unicode characters in base plot() and ggplot(), as any string with unicode will be blank. However, printing a plot (with either plot() or ggplot()) before attaching ragg fixes the issue:

library('ragg')
plot(1, xlab = '\U1D53C doesn\'t work')
ggplot2::ggplot() +
  ggplot2::geom_point(ggplot2::aes(1, 1)) +
  ggplot2::xlab('\U1D53C doesn\'t work')

# restart R (Ctrl + Shift + F10)

plot(1, xlab = '\U1D53C')
library('ragg')
plot(1, xlab = '\U1D53C now works')
ggplot2::ggplot() +
  ggplot2::geom_point(ggplot2::aes(1, 1)) +
  ggplot2::xlab('\U1D53C now works')

# restart R (Ctrl + Shift + F10)

ggplot2::ggplot() +
  ggplot2::geom_point(ggplot2::aes(1, 1)) +
  ggplot2::xlab('\U1D53C')
library('ragg')
plot(1, xlab = '\U1D53C now works')
ggplot2::ggplot() +
  ggplot2::geom_point(ggplot2::aes(1, 1)) +
  ggplot2::xlab('\U1D53C now works')

I am using R 4.2.1, RStudio 2022.07.1+554 "Spotted Wakerobin", and ragg 1.2.3 on Windows 10.

@thomasp85
Copy link
Member

I'm not able to reproduce this issue...

What do you get when you run systemfonts::system_fonts()

@StefanoMezzini
Copy link
Author

Thanks for the quick response! I've attached a csv with the output from systemfonts::system_fonts(). The issue occurs on both my laptop and my work computer.
fonts.csv

@thomasp85
Copy link
Member

Hi @StefanoMezzini — are you still experiencing this. If so, can I get you to provide a session info as well as let me know where you are observing the behaviour. The code snippet you provided indicates that you see it in the plot pane in RStudio / the graphics window in the R gui

@StefanoMezzini
Copy link
Author

Hi @thomasp85, I still have the same issue. Here is my session info before attaching ragg:

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.utf8  LC_CTYPE=English_Canada.utf8    LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.2 tools_4.2.2

and after attaching ragg:

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.utf8  LC_CTYPE=English_Canada.utf8    LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ragg_1.2.4

loaded via a namespace (and not attached):
[1] compiler_4.2.2    tools_4.2.2       rstudioapi_0.14   textshaping_0.3.6 systemfonts_1.0.4

If I run plot(1, xlab = '\U1D53C') first, then the session info becomes:

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.utf8  LC_CTYPE=English_Canada.utf8    LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.2  tools_4.2.2     rstudioapi_0.14

and attaching ragg now makes it

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.utf8  LC_CTYPE=English_Canada.utf8    LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ragg_1.2.4

loaded via a namespace (and not attached):
 [1] fansi_1.0.3       assertthat_0.2.1  dplyr_1.0.10      utf8_1.2.2        grid_4.2.2        R6_2.5.1          DBI_1.1.3         lifecycle_1.0.3  
 [9] gtable_0.3.1      magrittr_2.0.3    scales_1.2.1      ggplot2_3.4.0     pillar_1.8.1      rlang_1.0.6       cli_3.4.1         rstudioapi_0.14  
[17] generics_0.1.3    vctrs_0.5.0       textshaping_0.3.6 tools_4.2.2       glue_1.6.2        munsell_0.5.0     compiler_4.2.2    systemfonts_1.0.4
[25] pkgconfig_2.0.3   colorspace_2.0-3  tidyselect_1.2.0  tibble_3.1.8 

I've attached the plots that result from the first two calls of plot() and ggplot() from the code in my first comment. I am viewing the plots in the RStudio plot pane, but I get the same issue if I call png() or pdf() after attaching ragg without running plot(1, xlab = '\U1D53C') first. However, when I try saving the image to pdf, I get the warnings

Warning messages:
1: In title(...) :
  conversion failure on '𝔼 doesn't work' in 'mbcsToSbcs': dot substituted for <f0>
2: In title(...) :
  conversion failure on '𝔼 doesn't work' in 'mbcsToSbcs': dot substituted for <9d>
3: In title(...) :
  conversion failure on '𝔼 doesn't work' in 'mbcsToSbcs': dot substituted for <94>
4: In title(...) :
  conversion failure on '𝔼 doesn't work' in 'mbcsToSbcs': dot substituted for <bc>
5: In title(...) :
  conversion failure on '𝔼 doesn't work' in 'mbcsToSbcs': dot substituted for <f0>
6: In title(...) :
  conversion failure on '𝔼 doesn't work' in 'mbcsToSbcs': dot substituted for <9d>
7: In title(...) :
  conversion failure on '𝔼 doesn't work' in 'mbcsToSbcs': dot substituted for <94>
8: In title(...) :
  conversion failure on '𝔼 doesn't work' in 'mbcsToSbcs': dot substituted for <bc>

and the pdf I attached.

image
image
test.pdf

@thomasp85
Copy link
Member

So, you are experiencing issues, not with the ragg devices but with the default devices, and those issues seem to appear after you attach ragg?

@StefanoMezzini
Copy link
Author

I believe so? I am only using the default figure pane with the code in the first message, and I have updated ragg to 1.2.5.9000.

@thomasp85
Copy link
Member

And if you go into "global options">"general">"graphics", what does it say as the backend?

@StefanoMezzini
Copy link
Author

I have it set to (Default). Windows also fails, and Cairo and Cairo PNG produce boxes but no special characters, while AGG succeeds.

@thomasp85 thomasp85 transferred this issue from r-lib/ragg Oct 6, 2023
@thomasp85
Copy link
Member

@pmur002 this issue along with #35 is completely baffling to me

Somehow, loading textshaping interferes with the text rendering in various ways. Do you have any insight into what might cause this?

@jeroen
Copy link
Member

jeroen commented Oct 6, 2023

Can you try installing the latest dev versions and test if the problem still exists?

install.packages("textshaping", repos = "https://r-lib.r-universe.dev")

@pmur002
Copy link

pmur002 commented Oct 9, 2023

Off the top of my head, the only thing this reminds me of is FontConfig caching producing the wrong glyphs (in a very complicated set up).

@thomasp85
Copy link
Member

Thanks - this is unfortunately happening on windows so FontConfig doesn't play in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants