12345678910111213141516171819202122232425 |
- /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
- /* vim: set ts=2 et sw=2 tw=80: */
- /*************************************************************
- *
- * MathJax/jax/output/HTML-CSS/autoload/mglyph.js
- *
- * Implements the HTML-CSS output for <mglyph> elements.
- *
- * ---------------------------------------------------------------------
- *
- * Copyright (c) 2010-2013 The MathJax Consortium
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */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")});
|