r-lib/svglite

enhanced 'dev.capabilities()' support

trevorld opened this issue · 0 comments

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

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).