20 lines
81 KiB
JavaScript
20 lines
81 KiB
JavaScript
|
/*
|
||
|
* /MathJax-v2/jax/output/HTML-CSS/jax.js
|
||
|
*
|
||
|
* Copyright (c) 2009-2018 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.
|
||
|
*/
|
||
|
|
||
|
(function(j,b,d){var i,k=b.Browser.isMobile;var h=MathJax.Object.isArray;var e=function(){var m=[].slice.call(arguments,0);m[0][0]=["HTML-CSS",m[0][0]];return MathJax.Message.Set.apply(MathJax.Message,m)};var f=MathJax.Object.Subclass({timeout:(k?15:8)*1000,comparisonFont:["sans-serif","monospace","script","Times","Courier","Arial","Helvetica"],testSize:["40px","50px","60px","30px","20px"],FedoraSTIXcheck:{family:"STIXSizeOneSym",testString:"abcABC",noStyleChar:true},Init:function(){this.div=MathJax.HTML.addElement(document.body,"div",{style:{position:"absolute",width:0,height:0,overflow:"hidden",padding:0,border:0,margin:0}},[["div",{id:"MathJax_Font_Test",style:{position:"absolute",visibility:"hidden",top:0,left:0,width:"auto","min-width":0,"max-width":"none",padding:0,border:0,margin:0,whiteSpace:"nowrap",textAlign:"left",textIndent:0,textTransform:"none",lineHeight:"normal",letterSpacing:"normal",wordSpacing:"normal",fontSize:this.testSize[0],fontWeight:"normal",fontStyle:"normal",fontSizeAdjust:"none"}},[""]]]).firstChild;this.text=this.div.firstChild},findFont:function(r,o){var q=null;if(o&&this.testCollection(o)){q=o}else{for(var p=0,n=r.length;p<n;p++){if(r[p]===o){continue}if(this.testCollection(r[p])){q=r[p];break}}}if(q==="STIX"&&this.testFont(this.FedoraSTIXcheck)){q=null}return q},testCollection:function(n){var m={testString:"() {} []"};m.family={TeX:"MathJax_Size1",STIX:"STIXSizeOneSym"}[n]||n.replace(/-(Math)?/,"")+"MathJax_Size1";if(n==="STIX"){m.noStyleChar=true}return this.testFont(m)},testFont:function(p){if(p.isWebFont&&d.FontFaceBug){this.div.style.fontWeight=this.div.style.fontStyle="normal"}else{this.div.style.fontWeight=(p.weight||"normal");this.div.style.fontStyle=(p.style||"normal")}var r=p.familyFixed||p.family;if(!p.isWebFont&&!r.match(/^(STIX|MathJax)|'/)){r=r.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/ Jax/,"Jax")+"','"+r+"','"+r+"-";if(p.weight){r+="Bold"}if(p.style){r+="Italic"}if(!p.weight&&!p.style){r+="Regular"}p.familyFixed=r="'"+r+"'"}var o=this.getComparisonWidths(p.testString,p.noStyleChar);var s=null;if(o){this.div.style.fontFamily=r+","+this.comparisonFont[0];if(this.div.offsetWidth==o[0]){this.div.style.fontFamily=r+","+this.comparisonFont[o[2]];if(this.div.offsetWidth==o[1]){s=false}}if(s===null&&(this.div.offsetWidth!=o[3]||this.div.offsetHeight!=o[4])){if(!p.noStyleChar&&d.FONTDATA&&d.FONTDATA.hasStyleChar){for(var q=0,n=this.testSize.length;q<n;q++){if(this.testStyleChar(p,this.testSize[q])){s=true;n=0}}}else{s=true}}}if(d.safariTextNodeBug){this.div.innerHTML=""}else{this.text.nodeValue=""}return s},styleChar:"\uEFFD",versionChar:"\uEFFE",compChar:"\uEFFF",testStyleChar:function(p,r){var u=3+(p.weight?2:0)+(p.style?4:0);var o="",q=0;var t=this.div.style.fontSize;this.div.style.fontSize=r;if(d.msieItalicWidthBug&&p.style==="italic"){this.text.nodeValue=o=this.compChar;q=this.div.offsetWidth}if(d.safariTextNodeBug){this.div.innerHTML=this.compChar+o}else{this.text.nodeValue=this.compChar+o}var m=this.div.offsetWidth-q;if(d.safariTextNodeBug){this.div.innerHTML=this.styleChar+o}else{this.text.nodeValue=this.styleChar+o}var s=Math.floor((this.div.offsetWidth-q)/m+0.5);if(s===u){if(d.safariTextNodeBug){this.div.innerHTML=this.versionChar+o}else{this.text.nodeValue=this.versionChar+o}p.version=Math.floor((this.div.offsetWidth-q)/m+1.5)/2}this.div.style.fontSize=t;return(s===u)},getComparisonWidths:function(r,p){if(d.FONTDATA&&d.FONTDATA.hasStyleChar&&!p){r+=this.styleChar+" "+this.compChar}if(d.safariTextNodeBug){this.div.innerHTML=r}else{this.text.nodeValue=r}this.div.style.fontFamily=this.comparisonFont[0];var o=this.div.offsetWidth;this.div.style.fontFamily=d.webFontDefault;var t=this.div.offsetWidth,q=this.div.offsetHeight;for(var s=1,n=this.comparisonFont.length;s<n;s++){this.div.style.fontFamily=this.comparisonFont[s];if(this.div.offsetWidth!=o){return[o,this.div.offsetWidth,s,t,q]}}return null},loadWebFont:function(o){b.Startup.signal.Post("HTML-CSS Jax - Web-Font "+d.fontInUse+"/"+o.directory);var q=e(["LoadWebFont","Loading web-font %1",d.fontInUse+"/"
|