/* * /MathJax/jax/output/SVG/autoload/mglyph.js * * Copyright (c) 2009-2013 The MathJax Consortium * * Part of the MathJax library. * See http://www.mathjax.org for details. * * Licensed under the Apache License, Version 2.0; * you may not use this file except in compliance with the License. * * http://www.apache.org/licenses/LICENSE-2.0 */MathJax.Hub.Register.StartupHook("SVG Jax Ready",function(){var d=MathJax.ElementJax.mml,f=MathJax.OutputJax.SVG,e=f.BBOX,m=MathJax.Localization;e.MGLYPH=e.Subclass({type:"image",removeable:!1,Init:function(l,h,b,c,a,g){null==g&&(g={});var d=1E3*l.width/f.em,k=1E3*l.height/f.em,e=0;""!==h&&(d=f.length2em(h,a,d));""!==b&&(k=f.length2em(b,a,k));""!==c&&c.match(/\d/)&&(e=f.length2em(c,a),g.y=-e);g.height=Math.floor(k);g.width=Math.floor(d);g.transform="translate(0,"+k+") matrix(1 0 0 -1 0 0)";g.preserveAspectRatio="none";this.SUPER(arguments).Init.call(this,g);this.element.setAttributeNS("http://www.w3.org/1999/xlink","href",l.src);this.w=this.r=d;this.h=this.H=k+e;this.d=this.D=-e;this.l=0}});d.mglyph.Augment({toSVG:function(f,h){this.SVGgetStyles();var b=this.SVG(),c;this.SVGhandleSpace(b);var a=this.getValues("src","width","height","valign","alt");""===a.src?(a=this.getValues("index","fontfamily"),a.index&&(h||(h=this.SVGgetScale()),c={},a.fontfamily&&(c["font-family"]=a.fontfamily),b.Add(e.TEXT(h,String.fromCharCode(a.index),c)))):(this.img||(this.img=d.mglyph.GLYPH[a.src]),this.img||(this.img=d.mglyph.GLYPH[a.src]={img:new Image,status:"pending"},c=this.img.img,c.onload=MathJax.Callback(["SVGimgLoaded",this]),c.onerror=MathJax.Callback(["SVGimgError",this]),c.src=a.src,MathJax.Hub.RestartAfter(c.onload)),"OK"!==this.img.status?(b=d.merror(m._(["MathML","BadMglyph"],"Bad mglyph: %1",a.src)).With({mathsize:"75%"}),this.Append(b),b=b.toSVG(),this.data.pop()):(c=this.SVGgetMu(b),b.Add(e.MGLYPH(this.img.img,a.width,a.height,a.valign,c,{src:a.src,alt:a.alt,title:a.alt}))));b.Clean();this.SVGhandleColor(b);this.SVGsaveData(b);return b},SVGimgLoaded:function(d,e){"string"===typeof d&&(e=d);this.img.status=e||"OK"},SVGimgError:function(){this.img.img.onload("error")}},{GLYPH:{}});MathJax.Hub.Startup.signal.Post("SVG mglyph Ready");MathJax.Ajax.loadComplete(f.autoloadDir+"/mglyph.js")});