svglite icon indicating copy to clipboard operation
svglite copied to clipboard

enhanced 'dev.capabilities()' support

Open trevorld opened this issue 2 years ago • 0 comments

Currently {svglite} does not provide full information to the enhanced dev.capabilities() feature introduced in R 4.2:

  • https://developer.r-project.org/Blog/public/2021/12/14/updating-graphics-devices-for-r-4.2.0/
  • https://cran.r-project.org/doc/manuals/r-devel/R-ints.html#Device-capabilities
svglite::svglite(tempfile())
print(dev.capabilities())
dev.off()
$semiTransparency
[1] TRUE

$transparentBackground
[1] "fully"

$rasterImage
[1] NA

$capture
[1] FALSE

$locator
[1] FALSE

$events
character(0)

$patterns
[1] NA

$clippingPaths
[1] NA

$masks
[1] NA

$compositing
[1] FALSE

$transformations
[1] FALSE

$paths
[1] FALSE

I'm finding it difficult to reliably guess whether the active graphics device is being provided by svglite::svglite() or instead by vdiffr::write_svg() since in either case names(dev.cur()) == "devSVG". In the first case I'd like {gridpattern} / {ggpattern} to default to using the new alpha mask / gradient support whereas in the later case I need to fall back on a slower, rasterized alternative.

However if {svglite} added support for the new dev.capabilities() then I could simply rely on isTRUE(dev.capabilities()$clippingPaths) to tell if the active graphics device is provided by svglite::svglite() instead of vdiffr::write_svg() (when R >= 4.2).

trevorld avatar Mar 21 '22 17:03 trevorld