title: Golang vips: How to render text with custom truetype font?
body: <p>When we want to render text an vips image, you do something like this with <a href="http://www.vips.ecs.soton.ac.uk/supported/7.42/doc/html/libvips/libvips-create.html#vips-text" rel="nofollow">vips_text</a>:</p>
  
  <pre><code>    import "C"
      var textImage *C.VipsImage
      cText := C.CString("Some text")
      cFont := C.CString("Arial 12px")
      C.cgo_vips_text(&amp;textImage, cText, cFont)
  </code></pre>
  
  <p>But here, <code>Arial 12px</code> is a fontconfig string name and assumes that the system has this font installed. </p>
  
  <p>How do I let the program use a custom truetype font file, e.g., <code>Roboto.ttf</code>? </p>
  
  <p>Trying </p>
  
  <pre><code>cFont := C.CString("Roboto.ttf")
  </code></pre>
  
  <p>probably won't work.</p>
  
  <p>We could put the <code>Roboto.ttf</code> file in the system directory, for example, in Ubuntu you put the file in <code>/usr/share/fonts/truetype</code>, but the code makes the assumption that this font exists, which is not a solution to write machine-independent program. So I wonder if there is a better way to do this so that we can ship the executables with the font file together.</p>