tests/testthat/test-set-font.R

test_that("set_font returns an edited grob invisibly", {
  grDevices::pdf(file = tempfile(fileext = ".pdf"))
  on.exit(grDevices::dev.off(), add = TRUE)

  p <- ggplot2::ggplot(mtcars, ggplot2::aes(mpg, disp)) +
    ggplot2::geom_point() +
    ggplot2::labs(title = "mtcars")

  expect_s3_class(
    set_font(p, family = "serif", fontface = "italic", color = "firebrick"),
    "gtable"
  )
})

Try the ggfun package in your browser

Any scripts or data that you put into this service are public.

ggfun documentation built on July 3, 2026, 1:08 a.m.