r-lib / ragg

Graphic Devices Based on AGG
https://ragg.r-lib.org
Other
172 stars 24 forks source link

Inspect rendered glyph bitmap before deciding how to render it to page #121

Closed thomasp85 closed 1 year ago

thomasp85 commented 1 year ago

Fix #105

Surprisingly some of the glyphs from the windows emoji font is rendered as grey scale bitmaps, rather than in colour. This fix will inspect the pixel mode of the rendered bitmap and fall through to grey rendering if it is not BGRA

@yutannihilation can I get you to confirm that this fix solves the reported issue on your end as well?

yutannihilation commented 1 year ago

Confirmed, thanks so much!!

packageVersion("ragg")
#> [1] '1.2.4.9000'
packageDescription("ragg")$GithubSHA1
#> [1] "f8e2934e278606d8a7f31955154b6523bdff625e"

diamond <- "\u25C6"
diamond
#> [1] "◆"

do_plot <- function(dev) {
  file <- tempfile(fileext = ".png")
  dev(file)
  plot.new()
  text(0.5, 0.5, col = "red", cex = 30, label = diamond)
  dev.off()

  knitr::include_graphics(file)
}

do_plot(png)

do_plot(ragg::agg_png)

Created on 2023-01-12 with reprex v2.0.2