imageFonts.js 4.1 KB

12345678910111213
  1. /*
  2. * /MathJax/jax/output/HTML-CSS/imageFonts.js
  3. *
  4. * Copyright (c) 2009-2013 The MathJax Consortium
  5. *
  6. * Part of the MathJax library.
  7. * See http://www.mathjax.org for details.
  8. *
  9. * Licensed under the Apache License, Version 2.0;
  10. * you may not use this file except in compliance with the License.
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. */(function(l,d,k){l.Register.LoadHook(d.fontDir+"/fontdata.js",function(){d.Augment({allowWebFonts:!1,imgDir:d.webfontDir+"/png",imgPacked:MathJax.isPacked?"":"/unpacked",imgSize:["050","060","071","085",100,120,141,168,200,238,283,336,400,476],imgBaseIndex:4,imgSizeForEm:{},imgSizeForScale:{},imgZoom:1,handleImg:function(a,c,b,e,d){d.length&&this.addText(a,d);var g=b[5].orig;g||(g=b[5].orig=[b[0],b[1],b[2],b[3],b[4]]);d=this.imgZoom;a.scale||(a.scale=1);var f=this.imgIndex(a.scale*d);f==this.imgEmWidth.length-1&&1.1<this.em*a.scale*d/this.imgEmWidth[f]&&(d=this.imgEmWidth[f]/(this.em*a.scale));var h=this.imgEmWidth[f]/(this.em*(a.scale||1)*d);b[0]=g[0]*h;b[1]=g[1]*h;b[2]=g[2]*h;b[3]=g[3]*h;b[4]=g[4]*h;c=this.imgDir+"/"+c.directory+"/"+this.imgSize[f];for(e=e.toString(16).toUpperCase();4>e.length;)e="0"+e;e=c+"/"+e+".png";f=b[5].img[f];c={width:Math.floor(f[0]/d+.5)+"px",height:Math.floor(f[1]/d+.5)+"px"};f[2]&&(c.verticalAlign=Math.floor(-f[2]/d+.5)+"px");0>b[3]&&(c.marginLeft=this.Em(b[3]/1E3));b[4]!=b[2]&&(c.marginRight=this.Em((b[2]-b[4])/1E3));this.msieIE6&&(c.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src\x3d'"+k.fileURL(e)+"', sizingMethod\x3d'scale')",e=this.directory+"/blank.gif");this.addElement(a,"img",{src:k.fileURL(e),style:c,isMathJax:!0});return""},defineImageData:function(a){for(var c in a)if(a.hasOwnProperty(c)){var b=d.FONTDATA.FONTS[c];if(b){c=a[c];for(var e in c)c.hasOwnProperty(e)&&b[e]&&(b[e][5]={img:c[e]})}}},initImg:function(a){this.imgSizeForEm[this.em]&&(this.imgBaseIndex=this.imgSizeForEm[this.em]);a=0;for(var c=this.imgEmWidth.length-1;a<c&&!(this.em<=this.imgEmWidth[a]);a++);a&&this.imgEmWidth[a]-this.em>this.em-this.imgEmWidth[a-1]&&a--;this.imgSizeForEm[this.em]=this.imgBaseIndex=a;this.imgZoom=this.imgBrowserZoom()},imgIndex:function(a){if(!a)return this.imgBaseIndex;this.imgSizeForScale[this.em]||(this.imgSizeForScale[this.em]={});if(this.imgSizeForScale[this.em][a])return this.imgSizeForScale[this.em][a];for(var c=this.em*a,b=0,d=this.imgEmWidth.length-1;b<d&&!(c<=this.imgEmWidth[b]);b++);b&&this.imgEmWidth[b]-c>c-this.imgEmWidth[b-1]&&b--;return this.imgSizeForScale[this.em][a]=b},imgBrowserZoom:function(){return 1}});l.Browser.Select({Firefox:function(a){var c=d.addElement(document.body,"div",{style:{display:"none",visibility:"hidden",overflow:"scroll",position:"absolute",top:0,left:0,width:"200px",height:"200px",padding:0,border:0,margin:0}}),b=d.addElement(c,"div",{style:{position:"absolute",left:0,top:0,right:0,bottom:0,padding:0,border:0,margin:0}});d.Augment({imgSpaceBug:!0,imgSpace:"\u00a0",imgZoomLevel:a.isMac?{50:.3,30:.5,22:.67,19:.8,16:.9,15:1,13:1.1,12:1.2,11:1.33,10:1.5,9:1.7,7:2,6:2.4,5:3,0:15}:{56:.3,34:.5,25:.67,21:.8,19:.9,17:1,15:1.1,14:1.2,13:1.33,11:1.5,10:1.7,8:2,7:2.4,6:3,0:17},imgZoomDiv:c,imgBrowserZoom:function(){var a=this.imgZoomLevel;c.style.display="";var d=c.offsetWidth-b.offsetWidth,d=a[d]?a[d]:a[0]/d;c.style.display="none";return d}})},Safari:function(a){d.Augment({imgBrowserZoom:function(){return 3}})},Chrome:function(a){d.Augment({imgHeightBug:!0,imgBrowserZoom:function(){return 3}})},Opera:function(a){d.Augment({imgSpaceBug:!0,imgSpace:"\u00a0\u00a0",imgDoc:"BackCompat"==document.compatMode?document.body:document.documentElement,imgBrowserZoom:function(){if(a.isMac)return 3;var c=this.imgDoc.clientHeight,b=Math.floor(15*c/window.innerHeight);this.imgDoc.clientWidth<this.imgDoc.scrollWidth-b&&(c+=b);return parseFloat((window.innerHeight/c).toFixed(1))}})}});MathJax.Callback.Queue(["Require",k,d.imgDir+d.imgPacked+"/imagedata.js"],function(){var a=d.FONTDATA.FONTS.MathJax_Main[8212][5].img;d.imgEmWidth=[];for(var c=0,b=a.length;c<b;c++)d.imgEmWidth[c]=a[c][0]},["loadComplete",k,d.directory+"/imageFonts.js"])})})(MathJax.Hub,MathJax.OutputJax["HTML-CSS"],MathJax.Ajax);