/*! CanvasTextWrapper * https://github.com/namniak/CanvasTextWrapper * Version: 0.4.0 * MIT License (http://www.opensource.org/licenses/mit-license.html) */ !function(a){function b(a,b,c){"use strict";function d(){s=c.font.match(/\d+(px|em|%)/g)?+c.font.match(/\d+(px|em|%)/g)[0].match(/\d+/g):18,t=0,u=[],v=[],w={x:0,y:0},f(s),g(),o(),e()}function e(){if(c.sizeToFill){var a=b.trim().split(/\s+/).length,d=0;do f(++d),x=d,h();while(B>t&&u.join(" ").split(/\s+/).length==a);f(--d),x=d}else h();c.justifyLines&&"auto"===c.lineBreak&&k(),n(),l()}function f(a){var b=c.sizeToFill?r.font.split(/\b\d+px\b/i):c.font.split(/\b\d+px\b/i);r.font=b[0]+a+"px"+b[1]}function g(){isNaN(c.lineHeight)?-1!==c.lineHeight.toString().indexOf("px")?x=parseInt(c.lineHeight):-1!==c.lineHeight.toString().indexOf("%")&&(x=parseInt(c.lineHeight)/100*s):x=s*c.lineHeight}function h(){if(c.allowNewLine)for(var a=b.trim().split("\n"),d=0,e=0;dA){for(var g=0;r.measureText(b+a[f][g]).width<=A&&ga)&&(a=c,b=d);var e,f,g,h,i,j=" ";for(d=0;d=e))){u[d]=u[d].trim().split(/\s+/).join(j),f=r.measureText(j).width,g=(a-r.measureText(u[d]).width)/f,h=g/(e-1),i="";for(var k=0;h>k;k++)i+=j;u[d]=u[d].trim().split(j).join(i)}}function l(){for(var a=0;a