The length of the hyphen depends on the type of device (pdf, png) - how can I get short hyphens using pdf?

I want to use short hyphens for text using grid graphics like

txt <- "a dash-in between" 

The following examples show that the results differ depending on the output device (pdf, png).

 pdf("test.pdf") grid.text(txt) dev.off() 

enter image description here

 png("test.png") grid.text(txt) dev.off() 

enter image description here

The hyphen for a pdf device is much longer. What I want is a short hyphen using a pdf device. How can i do this?

+4
source share
1 answer

Try the cairo-based PDF device from grDevices ( cairo_pdf ):

 library("grid") txt <- "a dash-in between" cairo_pdf("test.pdf") grid.text(txt) dev.off() 

cairo_pdf example

Check capabilities() to see if cairo is supported on your system.

+2
source

Source: https://habr.com/ru/post/1500692/


All Articles