Closed z3tt closed 2 years ago
Any chance to investigate/solve that any time soon? I would love to use {camcorder} more regularly but in its current state, it's not useful at all for me. I would be happy to help @thebioengineer (if you tell me how :D)
Hey @z3tt - This is a problem with ggsave(), not gg_record() based on my testing:
> options(warn = -1)
>
> library(ggplot2)
>
> g <- ggplot(iris, aes(Sepal.Width, Sepal.Length)) + geom_point()
>
> theme_set(theme_minimal(base_family = "Roboto"))
> g
> ggsave("test.png", g, device = "png")
Saving 8.53 x 5.33 in image
> ggsave("test.png", g, device = "pdf")
Saving 8.53 x 5.33 in image
Error in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
invalid font type
Interesting, I didn't know! However, this works for me:
ggsave("test.pdf", g, device = cairo_pdf)
At least for Windows, it would be great to have cairo_pdf
as the default when saving to pdf. That would also fix the issue.
I have updated in PR #18 to accept functions, so cairo_pdf
is now an acceptable argument - I am hesitant to change from the "default" behavior of ggsave
, as my thought is gg_record
is an analogue to simply record on an ongoing basis.
Hi @thebioengineer, I have updated the branches and the package. However, when using a device function as argument for device
, e.g. device = ragg::agg_png()
, it throws an error that the argument does not match. I think it is due to the fact that is.function()
expects the function without parentheses, i.e. is.function(ragg::agg_png())
returns FALSE
and is.function(ragg::agg_png)
returns TRUE
. I am not sure what the correct way if I am using it incorrectly or if this is something we need to fix, so I'd appreciate any feedback.
Edit: btw, same is true when I try to use cairo_pdf
.
Thanks for pointing that out!
Works now thanks to #25 when passed as device = cairo_pdf
(without quotation marks as in ggsave()
)
Hey @thebioengineer, I found a strange issue when using the {systemfonts} package in combination with
gg_record()
and pdf output. Haven't used the package for a while but I am pretty sure we did use ragg/systemfonts back then as well. Do I miss something? Is there actually a way to specify the device, e.g. cairo_pdf?Here is a reprex:
Created on 2021-05-06 by the reprex package (v1.0.0)