Skip to content

Checks if svglite is installed when saving to svg. #6168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion R/save.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(...),
Expand Down
Loading