Skip to content

Commit 3faa53a

Browse files
authored
Checks if svglite is installed when saving to svg. (#6168)
Closes #6166
1 parent 2959336 commit 3faa53a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ documentation updates.
232232
* `annotate()` now warns about `stat` or `position` arguments (@teunbrand, #5151)
233233
* `guide_coloursteps(even.steps = FALSE)` now works with discrete data that has
234234
been formatted by `cut()` (@teunbrand, #3877).
235+
* `ggsave()` now offers to install svglite if needed (@eliocamp, #6166).
235236

236237
# ggplot2 3.5.0
237238

R/save.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ plot_dev <- function(device, filename = NULL, dpi = 300, call = caller_env()) {
277277
ps = eps,
278278
tex = function(filename, ...) grDevices::pictex(file = filename, ...),
279279
pdf = function(filename, ..., version = "1.4") grDevices::pdf(file = filename, ..., version = version),
280-
svg = function(filename, ...) svglite::svglite(file = filename, ...),
280+
svg = function(filename, ...) {
281+
check_installed("svglite", reason = "to save as SVG.")
282+
svglite::svglite(file = filename, ...)
283+
},
281284
# win.metafile() doesn't have `bg` arg so we need to absorb it before passing `...`
282285
emf = function(..., bg = NULL) grDevices::win.metafile(...),
283286
wmf = function(..., bg = NULL) grDevices::win.metafile(...),

0 commit comments

Comments
 (0)