diff --git a/NEWS.md b/NEWS.md index 540e662f0c..34750ee04c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -232,6 +232,7 @@ documentation updates. * `annotate()` now warns about `stat` or `position` arguments (@teunbrand, #5151) * `guide_coloursteps(even.steps = FALSE)` now works with discrete data that has been formatted by `cut()` (@teunbrand, #3877). +* `ggsave()` now offers to install svglite if needed (@eliocamp, #6166). # ggplot2 3.5.0 diff --git a/R/save.R b/R/save.R index ffe6945410..b06c567b2e 100644 --- a/R/save.R +++ b/R/save.R @@ -277,7 +277,10 @@ plot_dev <- function(device, filename = NULL, dpi = 300, call = caller_env()) { ps = eps, tex = function(filename, ...) grDevices::pictex(file = filename, ...), pdf = function(filename, ..., version = "1.4") grDevices::pdf(file = filename, ..., version = version), - svg = function(filename, ...) svglite::svglite(file = filename, ...), + svg = function(filename, ...) { + check_installed("svglite", reason = "to save as SVG.") + svglite::svglite(file = filename, ...) + }, # win.metafile() doesn't have `bg` arg so we need to absorb it before passing `...` emf = function(..., bg = NULL) grDevices::win.metafile(...), wmf = function(..., bg = NULL) grDevices::win.metafile(...),