-
Notifications
You must be signed in to change notification settings - Fork 24
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
Whitespace in expression is ignored #136
Comments
This was on a Linux machine, but I just tested and I don't see this in a windows machine. library(grid)
temp <- tempfile(fileext = ".png")
ragg::agg_png(temp, scaling = 4)
grid.newpage()
grid.draw(textGrob(expression(mu*" M")))
dev.off()
#> png
#> 2
knitr::include_graphics(temp) Created on 2023-10-04 with reprex v2.0.2 Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.0.5 (2021-03-31)
#> os Ubuntu 20.04.6 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Amsterdam
#> date 2023-10-04
#> pandoc 3.1.1 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> ! package * version date (UTC) lib source
#> cli 3.6.0 2023-01-09 [1] CRAN (R 4.0.5)
#> P curl 4.3 2019-12-02 [?] CRAN (R 4.0.5)
#> digest 0.6.31 2022-12-11 [1] CRAN (R 4.0.5)
#> evaluate 0.20 2023-01-17 [1] CRAN (R 4.0.5)
#> P fastmap 1.1.0 2021-01-25 [?] CRAN (R 4.0.5)
#> fs 1.6.1 2023-02-06 [1] CRAN (R 4.0.5)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.0.5)
#> highr 0.10 2022-12-22 [1] CRAN (R 4.0.5)
#> htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.0.5)
#> httr 1.4.5 2023-02-24 [1] CRAN (R 4.0.5)
#> knitr 1.42 2023-01-25 [1] CRAN (R 4.0.5)
#> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.0.5)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.0.5)
#> P mime 0.10 2021-02-13 [?] CRAN (R 4.0.5)
#> P png 0.1-7 2013-12-03 [?] CRAN (R 4.0.5)
#> purrr 1.0.1 2023-01-10 [1] CRAN (R 4.0.5)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.0.5)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.0.5)
#> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.0.5)
#> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.0.5)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.0.5)
#> ragg 1.2.5 2023-01-12 [1] CRAN (R 4.0.5)
#> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.0.5)
#> rlang 1.1.0 2023-03-14 [1] CRAN (R 4.0.5)
#> rmarkdown 2.20 2023-01-19 [1] CRAN (R 4.0.5)
#> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.0.5)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.0.5)
#> styler 1.9.1 2023-03-04 [1] CRAN (R 4.0.5)
#> systemfonts 1.0.4 2022-02-11 [1] CRAN (R 4.0.5)
#> textshaping 0.3.6 2021-10-13 [1] CRAN (R 4.0.5)
#> vctrs 0.6.1 2023-03-22 [1] CRAN (R 4.0.5)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 4.0.5)
#> xfun 0.37 2023-01-31 [1] CRAN (R 4.0.5)
#> xml2 1.3.3 2021-11-30 [1] CRAN (R 4.0.5)
#> P yaml 2.2.1 2020-02-01 [?] CRAN (R 4.0.5)
#>
#> [1] /DATA/home/t.vd.brand/R/x86_64-pc-linux-gnu-library/4.0
#> [2] /opt/R/4.0.5/lib/R/library
#>
#> P ── Loaded and on-disk path mismatch.
#>
#> ────────────────────────────────────────────────────────────────────────────── |
My best guess is that this is somewhat specific to the symbol font on your Linux system. plotmath expressions are rendered as single glyphs through the graphics engine so ragg has little to do with how the single glyphs are placed. I'd be happy to look into it in more detail if you share the fonts being used on your system (specifically what "Symbol" and "Sans" maps to) |
Yeah that might well be the case. Is there a way to specify which symbol font to use for plotmath expressions?
Sure, but I wouldn't place this right at the top of the priority queue :) systemfonts::font_info(c("sans", "symbol"))[, 2:9]
#> index family style italic bold monospace weight width
#> 1 0 DejaVu Sans Book FALSE FALSE FALSE normal normal
#> 2 0 Standard Symbols PS Regular FALSE FALSE FALSE normal normal Created on 2023-10-09 with reprex v2.0.2 |
Try |
Yep that worked, so this must be a font issue and nothing to do with ragg. Sorry for the noise! |
If I put a space in an expression, it seems as if the space isn't rendered.
In the example below, I had expected a space between 'µ' and 'M'.
It sort-of seems specific to the transition from non-plain-text elements (the µ) to plain text elements. Rendering
expression(mu*" M"*" F")
correctly puts a space between 'M' and 'F' but not 'µ' and 'M'.Created on 2023-06-21 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: