title: node-canvas: Using custom font
body: <p>I would like to know how to use custom font with node-canvas.</p>
  
  <p>Here is my attempt but it does not work so far:</p>
  
  <pre><code>var Canvas = require('canvas')
      , Image = Canvas.Image
      , Font = Canvas.Font
      , path = require('path');
  
  var gubblebum = new Font('gubblebum', fontFile('GUBBLO___.ttf'));
  
  function fontFile(name) {
    return path.join(__dirname, '../fonts', name);
  }
  
  function draw() {
    var canvas = new Canvas(100, 100)
      , ctx = canvas.getContext('2d');
  
    ctx.addFont(gubblebum);
    ctx.font = 'bold 40 gubblebum';
    ctx.fillText('test', 25, 45);
  
    return canvas;
  }
  
  module.exports = draw;
  </code></pre>
  
  <p>When rendered in a browser, the font is left unchanged from the default, as well as the size.</p>
  
  <p>The font file is correctly loaded. Otherwise, an exception would be thrown.</p>
  
  <p>Interestingly, when I do ctx.font = 'bold 40 someGibberish'; the font size is applied correctly.</p>