text: /**
   * Hilo 1.0.1 for kissy
   * Copyright 2016 alibaba.com
   * Licensed under the MIT License
   */
  KISSY.add("hilo/view/Text",function(t,e,i,n,o){var r=e.create({Extends:n,Mixes:o,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("Text"),r.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=r.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=r.measureFontHeight(t)),e},render:function(t,e){var i=this;t.canvas;if("canvas"===t.renderType)i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,o=n.domElement,r=o.style;r.font=i.font,r.textAlign=i.textAlign,r.color=i.color,r.width=i.width+"px",r.height=i.height+"px",r.lineHeight=i._fontHeight+i.lineSpacing+"px",o.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,o,r,h,l,a=i.split(/\r\n|\r|\n|<br(?:[ \/])*>/),s=0,c=0,d=e._fontHeight+e.lineSpacing,x=[];for(n=0,h=a.length;h>n;n++)if(o=a[n],r=t.measureText(o).width,r<=e.maxWidth)x.push({text:o,y:c}),r>s&&(s=r),c+=d;else{var g,f,u,w="",v=0;for(f=0,l=o.length;l>f;f++)u=o[f],g=t.measureText(w+u).width,g>e.maxWidth?(x.push({text:w,y:c}),v>s&&(s=v),c+=d,w=u):(v=g,w+=u),f==l-1&&(x.push({text:w,y:c}),w!==u&&g>s&&(s=g),c+=d)}e.textWidth=s,e.textHeight=c,e.width||(e.width=s),e.height||(e.height=c);var m=0;switch(e.textVAlign){case"middle":m=e.height-e.textHeight>>1;break;case"bottom":m=e.height-e.textHeight}var p=e.background;p&&(t.fillStyle=p,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color;for(var n=0;n<x.length;n++){var o=x[n];e._drawTextLine(t,o.text,m+o.y)}}},_drawTextLine:function(t,e,i){var n=this,o=0,r=n.width;switch(n.textAlign){case"center":o=r>>1;break;case"right":case"end":o=r}n.outline?t.strokeText(e,o,i):t.fillText(e,o,i)},Statics:{measureFontHeight:function(t){var e,n=document.documentElement,o=i.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(o),e=o.offsetHeight,n.removeChild(o),e}}});return r},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/view/View","hilo/view/CacheMixin"]});