mglyph.js 2.5 KB

12345678910111213141516171819
  1. /*
  2. * /MathJax/jax/output/CommonHTML/autoload/mglyph.js
  3. *
  4. * Copyright (c) 2009-2018 The MathJax Consortium
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function(){var c="2.7.5";var a=MathJax.ElementJax.mml,b=MathJax.OutputJax.CommonHTML,d=MathJax.Localization;a.mglyph.Augment({toCommonHTML:function(f,r){var o=this.getValues("src","width","height","valign","alt");f=this.CHTMLcreateNode(f);this.CHTMLhandleStyle(f);this.CHTMLhandleScale(f);if(o.src===""){var k=this.Get("index");this.CHTMLgetVariant();if(k&&this.CHTMLvariant.style){this.CHTMLhandleText(f,String.fromCharCode(k),this.CHTMLvariant)}}else{var p=this.CHTML;if(!p.img){p.img=a.mglyph.GLYPH[o.src]}if(!p.img){p.img=a.mglyph.GLYPH[o.src]={img:new Image(),status:"pending"};p.img.img.onload=MathJax.Callback(["CHTMLimgLoaded",this]);p.img.img.onerror=MathJax.Callback(["CHTMLimgError",this]);p.img.img.src=o.src;MathJax.Hub.RestartAfter(p.img.img.onload)}if(p.img.status!=="OK"){var g=a.Error(d._(["MathML","BadMglyph"],"Bad mglyph: %1",o.src));g.data[0].data[0].mathsize="75%";this.Append(g);g.toCommonHTML(f);this.data.pop();p.combine(g.CHTML,0,0,1)}else{var i=b.addElement(f,"img",{isMathJax:true,src:o.src,alt:o.alt,title:o.alt});var m=o.width,j=o.height;var e=p.img.img.width/b.em,n=p.img.img.height/b.em;var q=e,l=n;if(m!==""){e=this.CHTMLlength2em(m,q);n=(q?e/q*l:0)}if(j!==""){n=this.CHTMLlength2em(j,l);if(m===""){e=(l?n/l*q:0)}}i.style.width=b.Em(e);p.w=p.r=e;i.style.height=b.Em(n);p.h=p.t=n;if(o.valign){p.d=p.b=-this.CHTMLlength2em(o.valign,l);i.style.verticalAlign=b.Em(-p.d);p.h-=p.d;p.t=p.h}}}this.CHTMLhandleSpace(f);this.CHTMLhandleBBox(f);this.CHTMLhandleColor(f);return f},CHTMLimgLoaded:function(f,e){if(typeof(f)==="string"){e=f}this.CHTML.img.status=(e||"OK")},CHTMLimgError:function(){this.CHTML.img.img.onload("error")}},{GLYPH:{}});MathJax.Hub.Startup.signal.Post("CommonHTML mglyph Ready");MathJax.Ajax.loadComplete(b.autoloadDir+"/mglyph.js")});