title: Fabric.js clip text to rectangle
body: <p>I am using fabric.js to render objects on canvas. When I add text and change it's width, text is beyond selection area. How to clip text to rectangle that represents width and height properties?</p>
  
  <p>EDIT: This is the solution that I found to be working:</p>
  
  <pre><code>var text = 'Some text';        
  var textSample = new fabric.Text(text, textDefaults);
  
  textSample.clipTo = function (ctx) {
      ctx.rect(-textSample.width / 2, -textSample.height / 2, textSample.width, textSample.height );
  }
  
  canvas.add(textSample);
  </code></pre>
  
  <p>Where textDefaults is a text properties.</p>