//>>built
define("dojox/gfx/VectorText","dojo/_base/lang dojo/_base/declare dojo/_base/array dojo/_base/loader dojo/_base/xhr ./_base dojox/xml/DomParser dojox/html/metrics ./matrix".split(" "),function(u,C,n,H,D,k,E,F,v){var G=function(a){var b;D.get({url:a,sync:!0,load:function(a){b=a}});return b};u.getObject("dojox.gfx.VectorText",!0);u.mixin(k,{vectorFontFitting:{NONE:0,FLOW:1,FIT:2},defaultVectorText:{type:"vectortext",x:0,y:0,width:null,height:null,text:"",align:"start",decoration:"none",fitting:0,leading:1.5},
defaultVectorFont:{type:"vectorfont",size:"10pt",family:null},_vectorFontCache:{},_svgFontCache:{},getVectorFont:function(a){return k._vectorFontCache[a]?k._vectorFontCache[a]:new k.VectorFont(a)}});return C("dojox.gfx.VectorFont",null,{_entityRe:/&(quot|apos|lt|gt|amp|#x[^;]+|#\d+);/g,_decodeEntitySequence:function(a){if(a.match(this._entityRe)){for(var b={amp:"\x26",apos:"'",quot:'"',lt:"\x3c",gt:"\x3e"},f,c="";null!==(f=this._entityRe.exec(a));)c="x"==f[1].charAt(1)?c+String.fromCharCode(parseInt(f[1].slice(2),
16)):isNaN(parseInt(f[1].slice(1),10))?c+(b[f[1]]||""):c+String.fromCharCode(parseInt(f[1].slice(1),10));return c}},_parse:function(a,b){var f=k._svgFontCache[b]||E.parse(a),c=f.documentElement.byName("font")[0],e=f.documentElement.byName("font-face")[0],h=parseFloat(e.getAttribute("units-per-em")||1E3,10),g={x:parseFloat(c.getAttribute("horiz-adv-x"),10),y:parseFloat(c.getAttribute("vert-adv-y")||0,10)};g.y||(g.y=h);var c={horiz:{x:parseFloat(c.getAttribute("horiz-origin-x")||0,10),y:parseFloat(c.getAttribute("horiz-origin-y")||
0,10)},vert:{x:parseFloat(c.getAttribute("vert-origin-x")||0,10),y:parseFloat(c.getAttribute("vert-origin-y")||0,10)}},d=e.getAttribute("font-family"),p=e.getAttribute("font-style")||"all",m=e.getAttribute("font-variant")||"normal",v=e.getAttribute("font-weight")||"all",q=e.getAttribute("font-stretch")||"normal",t=e.getAttribute("unicode-range")||"U+0-10FFFF";e.getAttribute("panose-1");e.getAttribute("cap-height");var y=parseFloat(e.getAttribute("ascent")||h-c.vert.y,10),z=parseFloat(e.getAttribute("descent")||
c.vert.y,10),r={},l=d;e.byName("font-face-name")[0]&&(l=e.byName("font-face-name")[0].getAttribute("name"));if(!k._vectorFontCache[l]){n.forEach(["alphabetic","ideographic","mathematical","hanging"],function(a){var b=e.getAttribute(a);null!==b&&(r[a]=parseFloat(b,10))});var w=parseFloat(f.documentElement.byName("missing-glyph")[0].getAttribute("horiz-adv-x")||g.x,10),A={},x={},B=f.documentElement.byName("glyph");n.forEach(B,function(a){var b=a.getAttribute("unicode"),f=a.getAttribute("glyph-name"),
c=parseFloat(a.getAttribute("horiz-adv-x")||g.x,10);a=a.getAttribute("d");b.match(this._entityRe)&&(b=this._decodeEntitySequence(b));c={code:b,name:f,xAdvance:c,path:a};A[b]=c;x[f]=c},this);B=f.documentElement.byName("hkern");n.forEach(B,function(a,b){var f=-parseInt(a.getAttribute("k"),10),c=a.getAttribute("u1"),e=a.getAttribute("g1"),d=a.getAttribute("u2"),h=a.getAttribute("g2"),g;c?(c=this._decodeEntitySequence(c),A[c]&&(g=A[c])):x[e]&&(g=x[e]);g&&(g.kern||(g.kern={}),d?(d=this._decodeEntitySequence(d),
g.kern[d]={x:f}):x[h]&&(g.kern[x[h].code]={x:f}))},this);u.mixin(this,{family:d,name:l,style:p,variant:m,weight:v,stretch:q,range:t,viewbox:{width:h,height:h},origin:c,advance:u.mixin(g,{missing:{x:w,y:w}}),ascent:y,descent:z,baseline:r,glyphs:A});k._vectorFontCache[l]=this;k._vectorFontCache[b]=this;l==d||k._vectorFontCache[d]||(k._vectorFontCache[d]=this);k._svgFontCache[b]||(k._svgFontCache[b]=f)}},_clean:function(){var a=this.name,b=this.family;n.forEach("family name style variant weight stretch range viewbox origin advance ascent descent baseline glyphs".split(" "),
function(a){try{delete this[a]}catch(c){}},this);k._vectorFontCache[a]&&delete k._vectorFontCache[a];k._vectorFontCache[b]&&delete k._vectorFontCache[b];return this},constructor:function(a){this._defaultLeading=1.5;void 0!==a&&this.load(a)},load:function(a){this.onLoadBegin(a.toString());this._parse(k._svgFontCache[a.toString()]||G(a.toString()),a.toString());this.onLoad(this);return this},initialized:function(){return null!==this.glyphs},_round:function(a){return Math.round(1E3*a)/1E3},_leading:function(a){return this.viewbox.height*
(a||this._defaultLeading)},_normalize:function(a){return a.replace(/\s+/g,String.fromCharCode(32))},_getWidth:function(a){var b=0,f=0,c=null;n.forEach(a,function(e,h){f=e.xAdvance;a[h]&&e.kern&&e.kern[a[h].code]&&(f+=e.kern[a[h].code].x);b+=f;c=e});c&&" "==c.code&&(b-=c.xAdvance);return this._round(b)},_getLongestLine:function(a){var b=0,f=0;n.forEach(a,function(a,e){var c=Math.max(b,this._getWidth(a));c>b&&(b=c,f=e)},this);return{width:b,index:f,line:a[f]}},_trim:function(a){var b=function(a){a.length&&
(" "==a[a.length-1].code&&a.splice(a.length-1,1),a.length&&" "==a[0].code&&a.splice(0,1))};u.isArray(a[0])?n.forEach(a,b):b(a);return a},_split:function(a,b){for(var f=this._getWidth(a),f=Math.floor(f/b),c=[],e=0,h=[],g=!1,d=0,k=a.length;d<k;d++){" "==a[d].code&&(g=!0);e+=a[d].xAdvance;d+1<k&&a[d].kern&&a[d].kern[a[d+1].code]&&(e+=a[d].kern[a[d+1].code].x);if(e>=f){for(e=a[d];g&&" "!=e.code&&0<=d;)e=h.pop(),d--;c.push(h);h=[];e=0;g=!1}h.push(a[d])}h.length&&c.push(h);return this._trim(c)},_getSizeFactor:function(a){a+=
"";var b=F.getCachedFontMeasurements(),f=this.viewbox.height,c=b["1em"],c=parseFloat(a,10);if(-1<a.indexOf("em"))return this._round(b["1em"]*c/f);if(-1<a.indexOf("ex"))return this._round(b["1ex"]*c/f);if(-1<a.indexOf("pt"))return this._round(b["12pt"]/12*c/f);if(-1<a.indexOf("px"))return this._round(b["16px"]/16*c/f);if(-1<a.indexOf("%"))return this._round(c/100*b["1em"]/f);c=b[a]||b.medium;return this._round(c/f)},_getFitFactor:function(a,b,f,c){if(f){var e=this._getLongestLine(a).width;return this._round(Math.min(b/
e,f/(a.length*this.viewbox.height*c-(this.viewbox.height*c-this.viewbox.height))))}return this._round(b/this._getWidth(a))},_getBestFit:function(a,b,f,c){for(var e=32,h=0,g=e;0<e;){var d=this._getFitFactor(this._split(a,e),b,f,c);d>h&&(h=d,g=e);e--}return{scale:h,lines:this._split(a,g)}},_getBestFlow:function(a,b,f){for(var c=[],e=0,h=[],g=!1,d=0,k=a.length;d<k;d++){" "==a[d].code&&(g=!0);var m=a[d].xAdvance;d+1<k&&a[d].kern&&a[d].kern[a[d+1].code]&&(m+=a[d].kern[a[d+1].code].x);e+=f*m;if(e>=b){for(e=
a[d];g&&" "!=e.code&&0<=d;)e=h.pop(),d--;c.push(h);h=[];e=0;g=!1}h.push(a[d])}h.length&&c.push(h);return this._trim(c)},getWidth:function(a,b){return this._getWidth(n.map(this._normalize(a).split(""),function(a){return this.glyphs[a]||{xAdvance:this.advance.missing.x}},this))*(b||1)},getLineHeight:function(a){return this.viewbox.height*(a||1)},getCenterline:function(a){return this.viewbox.height/2*(a||1)},getBaseline:function(a){return(a||1)*(this.viewbox.height+this.descent)},draw:function(a,b,f,
c,e){if(!this.initialized())throw Error("dojox.gfx.VectorFont.draw(): we have not been initialized yet.");var h=a.createGroup();(b.x||b.y)&&a.applyTransform({dx:b.x||0,dy:b.y||0});var g=n.map(this._normalize(b.text).split(""),function(a){return this.glyphs[a]||{path:null,xAdvance:this.advance.missing.x}},this);a=f.size;var d=b.fitting,p=b.width,m=b.height;f=b.align;b=b.leading||this._defaultLeading;!d||(d!=k.vectorFontFitting.FLOW||p)&&(d!=k.vectorFontFitting.FIT||p&&m)||(d=k.vectorFontFitting.NONE);
switch(d){case k.vectorFontFitting.FIT:g=this._getBestFit(g,p,m,b);a=g.scale;g=g.lines;break;case k.vectorFontFitting.FLOW:a=this._getSizeFactor(a);g=this._getBestFlow(g,p,a);break;default:a=this._getSizeFactor(a),g=[g]}for(var g=n.filter(g,function(a){return 0<a.length}),p=0,d=this._getLongestLine(g).width,m=0,u=g.length;m<u;m++){for(var q=0,t=g[m],y=this._getWidth(t),z=h.createGroup(),r=0;r<t.length;r++){var l=t[r];if(null!==l.path){var w=z.createPath(l.path).setFill(c);e&&w.setStroke(e);w.setTransform([v.flipY,
v.translate(q,-this.viewbox.height-this.descent)])}q+=l.xAdvance;r+1<t.length&&l.kern&&l.kern[t[r+1].code]&&(q+=l.kern[t[r+1].code].x)}q=0;"middle"==f?q=d/2-y/2:"end"==f&&(q=d-y);z.setTransform({dx:q,dy:p});p+=this.viewbox.height*b}h.setTransform(v.scale(a));return h},onLoadBegin:function(a){},onLoad:function(a){}})});