Skip to content

Unicode text fails after attaching ragg #35

Closed

Description

@StefanoMezzini

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.

Activity

  1. thomasp85 commented on Sep 30, 2022

    @thomasp85
    Member

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

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

  2. StefanoMezzini commented on Sep 30, 2022

    @StefanoMezzini
    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

  3. thomasp85 commented on Jan 11, 2023

    @thomasp85
    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

  4. StefanoMezzini commented on Jan 18, 2023

    @StefanoMezzini
    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

  5. thomasp85 commented on Mar 7, 2023

    @thomasp85
    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?

  6. StefanoMezzini commented on Mar 9, 2023

    @StefanoMezzini
    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.

  7. thomasp85 commented on Mar 9, 2023

    @thomasp85
    Member

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

  8. StefanoMezzini commented on Mar 10, 2023

    @StefanoMezzini
    Author

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

  9. transferred this issue fromr-lib/raggon Oct 6, 2023
  10. thomasp85 commented on Oct 6, 2023

    @thomasp85
    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?

  11. jeroen commented on Oct 6, 2023

    @jeroen
    Member

    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")
  12. pmur002 commented on Oct 9, 2023

    @pmur002

    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).

  13. thomasp85 commented on Oct 10, 2023

    @thomasp85
    Member

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

  14. thomasp85 commented on Sep 30, 2025

    @thomasp85
    Member

    Fixed in latest systemfonts version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions