ragg icon indicating copy to clipboard operation
ragg copied to clipboard

Missing fonts in plot - Linux

Open brianmsm opened this issue 2 years ago • 1 comments

When ragg::agg_png is used to export the graphic and there is some symbol, it is not displayed. This does not happen with grDevices::png.

library(ggplot2)

grDevices::png("grDevices_image.png",
               width = 1000,
               height = 900,
               res = 400)
ggplot() +
  labs(subtitle = parse(text = "omega==2"))
dev.off()
#> png 
#>   2

Created on 2022-01-23 by the reprex package (v2.0.1)

grDevices_image

library(ggplot2)
ragg::agg_png("ragg_image.png",
              width = 1000,
              height = 900,
              res = 400)
ggplot() +
  labs(subtitle = parse(text = "omega==2"))
dev.off()
#> png 
#>   2

Created on 2022-01-23 by the reprex package (v2.0.1)

ragg_image

library(ggplot2)
library(ragg)

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Garuda Linux
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Lima
#>  date     2022-01-23
#>  pandoc   2.14.0.3 @ /usr/lib/rstudio/bin/pandoc/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.1.2)
#>  backports     1.4.1   2021-12-13 [1] CRAN (R 4.1.2)
#>  cli           3.1.1   2022-01-20 [1] CRAN (R 4.1.2)
#>  colorspace    2.0-2   2021-06-24 [1] CRAN (R 4.1.2)
#>  crayon        1.4.2   2021-10-29 [1] CRAN (R 4.1.2)
#>  DBI           1.1.2   2021-12-20 [1] CRAN (R 4.1.2)
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.1.2)
#>  dplyr         1.0.7   2021-06-18 [1] CRAN (R 4.1.2)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.2)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.1.2)
#>  fansi         1.0.2   2022-01-14 [1] CRAN (R 4.1.2)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.2)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.2)
#>  generics      0.1.1   2021-10-25 [1] CRAN (R 4.1.2)
#>  ggplot2     * 3.3.5   2021-06-25 [1] CRAN (R 4.1.2)
#>  glue          1.6.1   2022-01-22 [1] CRAN (R 4.1.2)
#>  gtable        0.3.0   2019-03-25 [1] CRAN (R 4.1.2)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.2)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.2)
#>  knitr         1.37    2021-12-16 [1] CRAN (R 4.1.2)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.2)
#>  magrittr      2.0.1   2020-11-17 [1] CRAN (R 4.1.2)
#>  munsell       0.5.0   2018-06-12 [1] CRAN (R 4.1.2)
#>  pillar        1.6.4   2021-10-18 [1] CRAN (R 4.1.2)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.2)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.2)
#>  R.cache       0.15.0  2021-04-30 [1] CRAN (R 4.1.2)
#>  R.methodsS3   1.8.1   2020-08-26 [1] CRAN (R 4.1.2)
#>  R.oo          1.24.0  2020-08-26 [1] CRAN (R 4.1.2)
#>  R.utils       2.11.0  2021-09-26 [1] CRAN (R 4.1.2)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.2)
#>  ragg        * 1.2.1   2021-12-06 [1] CRAN (R 4.1.2)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.2)
#>  rlang         0.4.12  2021-10-18 [1] CRAN (R 4.1.2)
#>  rmarkdown     2.11    2021-09-14 [1] CRAN (R 4.1.2)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.2)
#>  scales        1.1.1   2020-05-11 [1] CRAN (R 4.1.2)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.1.2)
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.2)
#>  styler        1.6.2   2021-09-23 [1] CRAN (R 4.1.2)
#>  systemfonts   1.0.3   2021-10-13 [1] CRAN (R 4.1.2)
#>  textshaping   0.3.6   2021-10-13 [1] CRAN (R 4.1.2)
#>  tibble        3.1.6   2021-11-07 [1] CRAN (R 4.1.2)
#>  tidyselect    1.1.1   2021-04-30 [1] CRAN (R 4.1.2)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.2)
#>  vctrs         0.3.8   2021-04-29 [1] CRAN (R 4.1.2)
#>  withr         2.4.3   2021-11-30 [1] CRAN (R 4.1.2)
#>  xfun          0.29    2021-12-14 [1] CRAN (R 4.1.2)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.1.2)
#> 
#>  [1] /home/brian/R/x86_64-pc-linux-gnu-library/4.1
#>  [2] /usr/lib/R/library
#> 
#> 

Created on 2022-01-23 by the reprex package (v2.0.1)

brianmsm avatar Jan 24 '22 00:01 brianmsm

I find that sometimes the default symbol font on Linux is pretty bad and either lead to missing glyphs or wrong dimensioning when setting up expressions. I'll see if I can somehow improve the default behaviour but otherwise it might make sense to set up a different default symbol font on your machine using fontconfig

thomasp85 avatar Aug 03 '22 08:08 thomasp85