s-u / Cairo

R graphics device using cairo graphics library for creating high-quality output
12 stars 10 forks source link

Grossly inconsistent font size between type="pdf" and type="png" #44

Closed zackw closed 3 months ago

zackw commented 1 year ago

The attached PNG and PDF were both rendered from an identical ggplot2 plot (dput(ggplotGrob(plot)) is also attached) using this procedure

save_Cairo <- function (filename, plot, type) {
    Cairo(width=10, height=4, units="cm", dpi=300, type=type, file=filename)
    print(plot)
    invisible(dev.off())
}

so the only difference is type="pdf" vs type="png". The PNG rendering is correct. In the PDF, however, every piece of text is much too large, as are all of the lines, and because the text takes up too much space, the plot is crushed into illegibility.

If there is a workaround of any sort, please advise.

font-size-bug.png font-size-bug.pdf plot.grob.txt.gz

s-u commented 11 months ago

@zackw The plot.grob.txt file doesn't work - please use saveRDS if you want to save R objects. Ideally, use a simple, reproducible example code.

s-u commented 3 months ago

Closing as no reproducible example was provided