yutannihilation / wgpugd

A WebGPU Graphics Device for R
https://yutannihilation.github.io/wgpugd/
Other
47 stars 3 forks source link

Font is slightly smaller #18

Open yutannihilation opened 2 years ago

yutannihilation commented 2 years ago

The texts are about 10% smaller. Why?

library(wgpugd)
library(ragg)

agg <- function(...) {
  agg_png(width = 7, height = 7, units = "in", ...)
}

do_text2 <- function(dev) {
  filename <- knitr::fig_path(paste0(deparse(substitute(dev)), ".png"))
  dev(filename = filename)

  grid::grid.text(
    x = grid::unit(0.5, "npc"),
    y = grid::unit(0.5, "npc"),
    label = "d",
    hjust = 0.5,
    vjust = 0,
    gp = grid::gpar(col = "brown", cex = 24, fontfamily = "Iosevka SS08")
  )

  f <- function(x, ...) {
    grid::grid.lines(
      x = grid::unit(c(0, 1), "npc"),
      y = grid::unit(rep(12, 2) * x, "points") + grid::unit(c(0.5, 0.5), "npc"),
      gp = grid::gpar(...)
    )
    invisible(NULL)
  }

  lapply(1:20, f, lty = 5, col = "purple", alpha = 0.7)
  lapply(0:2 * 10, f, col = "black")

  dev.off()

  knitr::include_graphics(filename)
}

do_text2(agg)
do_text2(wgpugd)

Created on 2022-02-20 by the reprex package (v2.0.1)