/* * /MathJax/jax/output/HTML-CSS/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("HTML-CSS Jax Ready",function(){var g=MathJax.ElementJax.mml,c=MathJax.OutputJax["HTML-CSS"],k=MathJax.Localization;g.mglyph.Augment({toHTML:function(a,h){var e=a,b=this.getValues("src","width","height","valign","alt");a=this.HTMLcreateSpan(a);if(""===b.src){var d=this.Get("index");if(d){h=this.HTMLgetVariant();var f=h.defaultFont;f&&(f.noStyleChar=!0,f.testString=String.fromCharCode(d)+"ABCabc",c.Font.testFont(f)?this.HTMLhandleVariant(a,h,String.fromCharCode(d)):(""===b.alt&&(b.alt=k._(["MathML","BadMglyphFont"],"Bad font: %1",f.family)),b=g.merror(b.alt).With({mathsize:"75%"}),this.Append(b),b.toHTML(a),this.data.pop(),a.bbox=b.HTMLspanElement().bbox))}}else this.img||(this.img=g.mglyph.GLYPH[b.src]),this.img||(this.img=g.mglyph.GLYPH[b.src]={img:new Image,status:"pending"},d=this.img.img,d.onload=MathJax.Callback(["HTMLimgLoaded",this]),d.onerror=MathJax.Callback(["HTMLimgError",this]),d.src=b.src,MathJax.Hub.RestartAfter(d.onload)),"OK"!==this.img.status?(b=g.merror(k._(["MathML","BadMglyph"],"Bad mglyph: %1",b.src)).With({mathsize:"75%"}),this.Append(b),b.toHTML(a),this.data.pop(),a.bbox=b.HTMLspanElement().bbox):(f=this.HTMLgetMu(a),d=c.addElement(a,"img",{isMathJax:!0,src:b.src,alt:b.alt,title:b.alt}),b.width&&(String(b.width).match(/^\s*-?\d+\s*$/)&&(b.width+="px"),d.style.width=c.Em(c.length2em(b.width,f,this.img.img.width/c.em))),b.height&&(String(b.height).match(/^\s*-?\d+\s*$/)&&(b.height+="px"),d.style.height=c.Em(c.length2em(b.height,f,this.img.img.height/c.em))),a.bbox.w=a.bbox.rw=d.offsetWidth/c.em,a.bbox.h=d.offsetHeight/c.em,b.valign&&(String(b.valign).match(/^\s*-?\d+\s*$/)&&(b.valign+="px"),a.bbox.d=-c.length2em(b.valign,f,this.img.img.height/c.em),d.style.verticalAlign=c.Em(-a.bbox.d),a.bbox.h-=a.bbox.d));e.bbox?a.bbox&&(e.bbox.w+=a.bbox.w,e.bbox.w>e.bbox.rw&&(e.bbox.rw=e.bbox.w),a.bbox.h>e.bbox.h&&(e.bbox.h=a.bbox.h),a.bbox.d>e.bbox.d&&(e.bbox.d=a.bbox.d)):e.bbox={w:a.bbox.w,h:a.bbox.h,d:a.bbox.d,rw:a.bbox.rw,lw:a.bbox.lw};this.HTMLhandleSpace(a);this.HTMLhandleColor(a);return a},HTMLimgLoaded:function(a,c){"string"===typeof a&&(c=a);this.img.status=c||"OK"},HTMLimgError:function(){this.img.img.onload("error")}},{GLYPH:{}});MathJax.Hub.Startup.signal.Post("HTML-CSS mglyph Ready");MathJax.Ajax.loadComplete(c.autoloadDir+"/mglyph.js")});