Itext not update boundingrect when change google font weight and font style
by tinyhustlee
HTML
<script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script>
<script src="https://rawgit.com/bramstein/fontfaceobserver/master/fontfaceobserver.js"></script>
<style>
@import url('https://fonts.googleapis.com/css?family=Roboto:400,400i,700,700i');
</style>
<canvas id="c" style="width: 500px; height: 500px;"></canvas>
JavaScript
var canvas = new fabric.Canvas('c');
canvas.setDimensions({'width' : 500, 'height' : 500});
var text = new fabric.IText('Font Weigh, Font Style', {
left: 50,
top: 50,
width: 450,
fontSize: 30,
objectCaching: false,
fontFamily: 'Roboto',
fontStyle: 'italic',
fontWeight: 'bold'
});
canvas.add(text).setActiveObject(text);
var myfont = new FontFaceObserver('Roboto')
myfont.load()
.then(function() {
canvas.renderAll();
}).catch(function(e) {
console.log(e)
alert('font loading failed ' + font);
});