title: Figure space in EPS plots
body: <p>When drawing labels or legends in plots, it's sometimes useful to use figure spaces, unicode U+2007, to properly align figures with a different numbers of digits. For the on-screen device, simply embedding <code>\u2007</code> in the output makes this work reasonably well (and better on Windows or with <code>X11(type="Xlib")</code> than with my Linux default using cairo).</p>
  
  <pre><code>plot(runif(20), ylim=c(0,1.2), pch=c("x", "o"))
  legend("top", c("\u20075%", "10%"), pch=c("x", "o"))
  </code></pre>
  
  <p>But when I set the output device to postscript in order to create an EPS file, things break:</p>
  
  <pre><code>setEPS()
  postscript()
  plot(runif(20), ylim=c(0,1.2), pch=c("x", "o"))
  legend("top", c("\u20075%", "10%"), pch=c("x", "o"))
  dev.off()
  </code></pre>
  
  <p>will result in messages like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>Warning messages:
  1: In strwidth(legend, units = "user", cex = cex, font = text.font) :
    conversion failure on ' 5%' in 'mbcsToSbcs': dot substituted for &lt;e2&gt;
  </code></pre>
  
  <p>The same message gets repeated for <code>&lt;80&gt;</code> and <code>&lt;87&gt;</code> which together form the UTF-8 sequence of U+2007. The whole thing repeats three times for different function invocations.</p>
  
  <p><strong>Is there some magic which I can use to make this work?</strong> I can think of two possible approaches.</p>
  
  <ol>
  <li><p>One would be creating my own font encoding which makes the character accessible. But I don't know the Postscript font name for figure space, and I don't know how to find out. I also guess that I might have to choose NimbusSan or some other font which has a sufficient set of glyphs, since ancient Helvetica likely won't have that specified.</p></li>
  <li><p>The other approach I can think of would be somehow letting the postscript engine know that this is a spacing symbol and that instead of actually printing something, a suitable amount of kerning can be introduced instead. Perhaps one can do this with the right fond metric file. But where to get that?</p></li>
  </ol>
  
  <p>It might well be that these two approaches have to be mixed in some fashion, that choosing a good font requires using a good font metrics file, or that to use kerning I still have to ensure some single-bit encoding which can carry that character.</p>