title: corrupted UTF characters in pdf plots generated by R
body: <p>I am trying to save plots with legends containing UTF characters for Males and Females to pdf in <code>R</code>. When I plot to graphics device :</p>
  
  <pre><code>plot(1)
  legend('topright', bty = 'n', 
         expression(italic("legend"~"\u2640"~"\u2642")))
  </code></pre>
  
  <p>the legend of plot looks as expected</p>
  
  <p><a href="https://i.stack.imgur.com/wjlnp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wjlnp.png" alt="enter image description here"></a></p>
  
  <p>I can even save it to pdf by right click and "save to pdf". However, when I use inbuilt function <code>pdf</code></p>
  
  <pre><code>pdf('test.pdf')
  plot(1)
  legend('topright', bty = 'n',
         expression(italic("legend"~"\u2640"~"\u2642")))
  dev.off()
  </code></pre>
  
  <p>it drops a warning and shows corrupted characters instead:</p>
  
  <p><a href="https://i.stack.imgur.com/dPec7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dPec7.png" alt="enter image description here"></a></p>
  
  <p><code>cairo_pdf</code> does not drop a warning, but it does not show the correct symbols either:</p>
  
  <p><a href="https://i.stack.imgur.com/y2ERl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y2ERl.png" alt="enter image description here"></a></p>
  
  <p>According to <a href="https://stackoverflow.com/questions/12096152/plotting-symbols-fails-in-pdf">this post</a>, I should specify encoding that would support my symbols, however I have no idea how to find out which it does (besides default <code>Helvetica</code> I tried <code>MacRoman</code> without success).</p>
  
  <p>It is apparent that it is possible for R to generate pdf that contains these symbols (because I am able to do so by the right click). However, I would like to achieve that in automatized manner.</p>
  
  <p>My R session settings:</p>
  
  <pre><code>R version 3.3.1 (2016-06-21)
  Platform: x86_64-apple-darwin13.4.0 (64-bit)
  Running under: OS X 10.11.5 (El Capitan)
  
  locale:
  [1] en_US.UTF-8/C/en_US.UTF-8/C/en_US.UTF-8/C
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base    
  </code></pre>
  
  <p>I also managed to reproduce same behaviour on another computer with macOS Sierra 10.12.1.</p>