Change String().fromCharCode() to direct \uXXXX in a string, and make em and ex sizes be vertical rather than horizontal (this was confusing browsers on mobile devices, where the width wasn't big enough for the number of ems used to determine the size)

This commit is contained in:
Davide P. Cervone 2011-11-03 17:09:45 -04:00
parent 6e59642e7a
commit a5812c6e43
16 changed files with 48 additions and 48 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
*/ */
(function(b,c,a){var d="1.1.1";b.Register.LoadHook(c.fontDir+"/fontdata.js",function(){c.Augment({allowWebFonts:false,imgDir:c.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(t,i,r,h,u){if(u.length){this.addText(t,u)}var s=r[5].orig;if(!s){s=r[5].orig=[r[0],r[1],r[2],r[3],r[4]]}var m=this.imgZoom;if(!t.scale){t.scale=1}var p=this.imgIndex(t.scale*m);if(p==this.imgEmWidth.length-1&&this.em*t.scale*m/this.imgEmWidth[p]>1.1){m=this.imgEmWidth[p]/(this.em*t.scale)}var q=this.imgEmWidth[p]/(this.em*(t.scale||1)*m);r[0]=s[0]*q;r[1]=s[1]*q;r[2]=s[2]*q;r[3]=s[3]*q;r[4]=s[4]*q;var k=this.imgDir+"/"+i.directory+"/"+this.imgSize[p];var l=h.toString(16).toUpperCase();while(l.length<4){l="0"+l}var j=k+"/"+l+".png";var o=r[5].img[p];var g={width:Math.floor(o[0]/m+0.5)+"px",height:Math.floor(o[1]/m+0.5)+"px"};if(o[2]){g.verticalAlign=Math.floor(-o[2]/m+0.5)+"px"}if(r[3]<0){g.marginLeft=this.Em(r[3]/1000)}if(r[4]!=r[2]){g.marginRight=this.Em((r[2]-r[4])/1000)}if(this.msieIE6){g.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a.fileURL(j)+"', sizingMethod='scale')";j=this.directory+"/blank.gif"}this.addElement(t,"img",{src:a.fileURL(j),style:g,isMathJax:true});return""},defineImageData:function(i){for(var g in i){if(i.hasOwnProperty(g)){var h=c.FONTDATA.FONTS[g];if(h){g=i[g];for(var j in g){if(g.hasOwnProperty(j)&&h[j]){h[j][5]={img:g[j]}}}}}}},initImg:function(j){if(this.imgSizeForEm[this.em]){this.imgBaseIndex=this.imgSizeForEm[this.em]}for(var h=0,g=this.imgEmWidth.length-1;h<g;h++){if(this.em<=this.imgEmWidth[h]){break}}if(h&&this.imgEmWidth[h]-this.em>this.em-this.imgEmWidth[h-1]){h--}this.imgSizeForEm[this.em]=this.imgBaseIndex=h;this.imgZoom=this.imgBrowserZoom()},imgIndex:function(k){if(!k){return this.imgBaseIndex}if(!this.imgSizeForScale[this.em]){this.imgSizeForScale[this.em]={}}if(this.imgSizeForScale[this.em][k]){return this.imgSizeForScale[this.em][k]}var j=this.em*k;for(var h=0,g=this.imgEmWidth.length-1;h<g;h++){if(j<=this.imgEmWidth[h]){break}}if(h&&this.imgEmWidth[h]-j>j-this.imgEmWidth[h-1]){h--}this.imgSizeForScale[this.em][k]=h;return h},imgBrowserZoom:function(){return 1}});b.Browser.Select({Firefox:function(h){var g=c.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}});var i=c.addElement(g,"div",{style:{position:"absolute",left:0,top:0,right:0,bottom:0,padding:0,border:0,margin:0}});c.Augment({imgSpaceBug:true,imgSpace:String.fromCharCode(160),imgZoomLevel:(h.isMac?{50:0.3,30:0.5,22:0.67,19:0.8,16:0.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:0.3,34:0.5,25:0.67,21:0.8,19:0.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:g,imgBrowserZoom:function(){var j=this.imgZoomLevel;g.style.display="";var k=(g.offsetWidth-i.offsetWidth);k=(j[k]?j[k]:j[0]/k);g.style.display="none";return k}})},Safari:function(g){c.Augment({imgBrowserZoom:function(){return 3}})},Chrome:function(g){c.Augment({imgHeightBug:true,imgBrowserZoom:function(){return 3}})},Opera:function(g){c.Augment({imgSpaceBug:true,imgSpace:String.fromCharCode(160)+String.fromCharCode(160),imgDoc:(document.compatMode=="BackCompat"?document.body:document.documentElement),imgBrowserZoom:function(){if(g.isMac){return 3}var h=this.imgDoc.clientHeight,i=Math.floor(15*h/window.innerHeight);if(this.imgDoc.clientWidth<this.imgDoc.scrollWidth-i){h+=i}return parseFloat((window.innerHeight/h).toFixed(1))}})}});var f=function(){var h=c.FONTDATA.FONTS.MathJax_Main[8212][5].img;c.imgEmWidth=[];for(var j=0,g=h.length;j<g;j++){c.imgEmWidth[j]=h[j][0]}};var e=c.imgDir+c.imgPacked;MathJax.Callback.Queue(["Require",a,e+"/imagedata.js"],f,["loadComplete",a,c.directory+"/imageFonts.js"])})})(MathJax.Hub,MathJax.OutputJax["HTML-CSS"],MathJax.Ajax); (function(b,c,a){var d="1.1.1";b.Register.LoadHook(c.fontDir+"/fontdata.js",function(){c.Augment({allowWebFonts:false,imgDir:c.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(t,i,r,h,u){if(u.length){this.addText(t,u)}var s=r[5].orig;if(!s){s=r[5].orig=[r[0],r[1],r[2],r[3],r[4]]}var m=this.imgZoom;if(!t.scale){t.scale=1}var p=this.imgIndex(t.scale*m);if(p==this.imgEmWidth.length-1&&this.em*t.scale*m/this.imgEmWidth[p]>1.1){m=this.imgEmWidth[p]/(this.em*t.scale)}var q=this.imgEmWidth[p]/(this.em*(t.scale||1)*m);r[0]=s[0]*q;r[1]=s[1]*q;r[2]=s[2]*q;r[3]=s[3]*q;r[4]=s[4]*q;var k=this.imgDir+"/"+i.directory+"/"+this.imgSize[p];var l=h.toString(16).toUpperCase();while(l.length<4){l="0"+l}var j=k+"/"+l+".png";var o=r[5].img[p];var g={width:Math.floor(o[0]/m+0.5)+"px",height:Math.floor(o[1]/m+0.5)+"px"};if(o[2]){g.verticalAlign=Math.floor(-o[2]/m+0.5)+"px"}if(r[3]<0){g.marginLeft=this.Em(r[3]/1000)}if(r[4]!=r[2]){g.marginRight=this.Em((r[2]-r[4])/1000)}if(this.msieIE6){g.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a.fileURL(j)+"', sizingMethod='scale')";j=this.directory+"/blank.gif"}this.addElement(t,"img",{src:a.fileURL(j),style:g,isMathJax:true});return""},defineImageData:function(i){for(var g in i){if(i.hasOwnProperty(g)){var h=c.FONTDATA.FONTS[g];if(h){g=i[g];for(var j in g){if(g.hasOwnProperty(j)&&h[j]){h[j][5]={img:g[j]}}}}}}},initImg:function(j){if(this.imgSizeForEm[this.em]){this.imgBaseIndex=this.imgSizeForEm[this.em]}for(var h=0,g=this.imgEmWidth.length-1;h<g;h++){if(this.em<=this.imgEmWidth[h]){break}}if(h&&this.imgEmWidth[h]-this.em>this.em-this.imgEmWidth[h-1]){h--}this.imgSizeForEm[this.em]=this.imgBaseIndex=h;this.imgZoom=this.imgBrowserZoom()},imgIndex:function(k){if(!k){return this.imgBaseIndex}if(!this.imgSizeForScale[this.em]){this.imgSizeForScale[this.em]={}}if(this.imgSizeForScale[this.em][k]){return this.imgSizeForScale[this.em][k]}var j=this.em*k;for(var h=0,g=this.imgEmWidth.length-1;h<g;h++){if(j<=this.imgEmWidth[h]){break}}if(h&&this.imgEmWidth[h]-j>j-this.imgEmWidth[h-1]){h--}this.imgSizeForScale[this.em][k]=h;return h},imgBrowserZoom:function(){return 1}});b.Browser.Select({Firefox:function(h){var g=c.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}});var i=c.addElement(g,"div",{style:{position:"absolute",left:0,top:0,right:0,bottom:0,padding:0,border:0,margin:0}});c.Augment({imgSpaceBug:true,imgSpace:"\u00A0",imgZoomLevel:(h.isMac?{50:0.3,30:0.5,22:0.67,19:0.8,16:0.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:0.3,34:0.5,25:0.67,21:0.8,19:0.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:g,imgBrowserZoom:function(){var j=this.imgZoomLevel;g.style.display="";var k=(g.offsetWidth-i.offsetWidth);k=(j[k]?j[k]:j[0]/k);g.style.display="none";return k}})},Safari:function(g){c.Augment({imgBrowserZoom:function(){return 3}})},Chrome:function(g){c.Augment({imgHeightBug:true,imgBrowserZoom:function(){return 3}})},Opera:function(g){c.Augment({imgSpaceBug:true,imgSpace:"\u00A0\u00A0",imgDoc:(document.compatMode=="BackCompat"?document.body:document.documentElement),imgBrowserZoom:function(){if(g.isMac){return 3}var h=this.imgDoc.clientHeight,i=Math.floor(15*h/window.innerHeight);if(this.imgDoc.clientWidth<this.imgDoc.scrollWidth-i){h+=i}return parseFloat((window.innerHeight/h).toFixed(1))}})}});var f=function(){var h=c.FONTDATA.FONTS.MathJax_Main[8212][5].img;c.imgEmWidth=[];for(var j=0,g=h.length;j<g;j++){c.imgEmWidth[j]=h[j][0]}};var e=c.imgDir+c.imgPacked;MathJax.Callback.Queue(["Require",a,e+"/imagedata.js"],f,["loadComplete",a,c.directory+"/imageFonts.js"])})})(MathJax.Hub,MathJax.OutputJax["HTML-CSS"],MathJax.Ajax);

File diff suppressed because one or more lines are too long

View File

@ -202,7 +202,7 @@ MathJax.ElementJax.mml.Augment({
VCENTER: 8, VCENTER: 8,
NONE: -1 NONE: -1
}, },
PLANE1: String.fromCharCode(0xD835) PLANE1: "\uD835"
}); });
(function (MML) { (function (MML) {

View File

@ -24,7 +24,7 @@
*/ */
(function (TEX,HUB,AJAX) { (function (TEX,HUB,AJAX) {
var TRUE = true, FALSE = false, MML, NBSP = String.fromCharCode(0xA0); var TRUE = true, FALSE = false, MML, NBSP = "\u00A0";
var STACK = MathJax.Object.Subclass({ var STACK = MathJax.Object.Subclass({
Init: function (env,inner) { Init: function (env,inner) {
@ -1115,7 +1115,7 @@
} }
this.Push(STACKITEM.subsup(base).With({position: position})); this.Push(STACKITEM.subsup(base).With({position: position}));
}, },
PRIME: String.fromCharCode(0x2032), SMARTQUOTE: String.fromCharCode(0x2019), PRIME: "\u2032", SMARTQUOTE: "\u2019",
Prime: function (c) { Prime: function (c) {
var base = this.stack.Prev(); if (!base) {base = MML.mi()} var base = this.stack.Prev(); if (!base) {base = MML.mi()}
if (base.type === "msubsup" && base.data[base.sup]) if (base.type === "msubsup" && base.data[base.sup])
@ -1196,7 +1196,7 @@
}, },
NamedOp: function (name,id) { NamedOp: function (name,id) {
if (!id) {id = name.substr(1)}; if (!id) {id = name.substr(1)};
id = id.replace(/&thinsp;/,String.fromCharCode(0x2006)); id = id.replace(/&thinsp;/,"\u2006");
var mml = MML.mo(id).With({ var mml = MML.mo(id).With({
movablelimits: TRUE, movablelimits: TRUE,
movesupsub: TRUE, movesupsub: TRUE,

View File

@ -120,7 +120,7 @@
HTMLCSS.Augment({ HTMLCSS.Augment({
imgSpaceBug: true, imgSpaceBug: true,
imgSpace: String.fromCharCode(0xA0), imgSpace: "\u00A0",
imgZoomLevel: (browser.isMac ? imgZoomLevel: (browser.isMac ?
{50:.3, 30:.5, 22:.67, 19:.8, 16:.9, 15:1, 13:1.1, 12:1.2, {50:.3, 30:.5, 22:.67, 19:.8, 16:.9, 15:1, 13:1.1, 12:1.2,
@ -162,7 +162,7 @@
Opera: function (browser) { Opera: function (browser) {
HTMLCSS.Augment({ HTMLCSS.Augment({
imgSpaceBug: true, imgSpaceBug: true,
imgSpace: String.fromCharCode(0xA0)+String.fromCharCode(0xA0), imgSpace: "\u00A0\u00A0",
imgDoc: (document.compatMode == "BackCompat" ? document.body : imgDoc: (document.compatMode == "BackCompat" ? document.body :
document.documentElement), document.documentElement),

View File

@ -246,11 +246,11 @@
".MathJax_ExBox": { ".MathJax_ExBox": {
display:"block", overflow:"hidden", display:"block", overflow:"hidden",
height:"1px", width:"60ex" width:"1px", height:"60ex"
}, },
".MathJax .MathJax_EmBox": { ".MathJax .MathJax_EmBox": {
display:"block", overflow:"hidden", display:"block", overflow:"hidden",
height:"1px", width:"60em" width:"1px", height:"60em"
}, },
".MathJax .MathJax_HitBox": { ".MathJax .MathJax_HitBox": {
@ -407,8 +407,8 @@
// //
document.body.appendChild(this.EmExSpan); document.body.appendChild(this.EmExSpan);
document.body.appendChild(this.linebreakSpan); document.body.appendChild(this.linebreakSpan);
this.defaultEx = this.EmExSpan.firstChild.offsetWidth/60; this.defaultEx = this.EmExSpan.firstChild.offsetHeight/60;
this.defaultEm = this.EmExSpan.lastChild.firstChild.offsetWidth/60; this.defaultEm = this.EmExSpan.lastChild.firstChild.offsetHeight/60;
this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth; this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth;
document.body.removeChild(this.linebreakSpan); document.body.removeChild(this.linebreakSpan);
document.body.removeChild(this.EmExSpan); document.body.removeChild(this.EmExSpan);
@ -476,8 +476,8 @@
script = scripts[i]; if (!script.parentNode) continue; script = scripts[i]; if (!script.parentNode) continue;
test = script.previousSibling; div = test.previousSibling; test = script.previousSibling; div = test.previousSibling;
jax = script.MathJax.elementJax; jax = script.MathJax.elementJax;
ex = test.firstChild.offsetWidth/60; ex = test.firstChild.offsetHeight/60;
em = test.lastChild.firstChild.offsetWidth/60; em = test.lastChild.firstChild.offsetHeight/60;
if (relwidth) {maxwidth = div.previousSibling.firstChild.offsetWidth} if (relwidth) {maxwidth = div.previousSibling.firstChild.offsetWidth}
if (ex === 0 || ex === "NaN") { if (ex === 0 || ex === "NaN") {
// can't read width, so move to hidden div for processing // can't read width, so move to hidden div for processing
@ -625,7 +625,7 @@
// get em sizes (taken from HTMLCSS.preTranslate) // get em sizes (taken from HTMLCSS.preTranslate)
// //
var emex = span.appendChild(this.EmExSpan.cloneNode(true)); var emex = span.appendChild(this.EmExSpan.cloneNode(true));
var em = emex.lastChild.firstChild.offsetWidth/60; var em = emex.lastChild.firstChild.offsetHeight/60;
this.em = MML.mbase.prototype.em = em; this.em = MML.mbase.prototype.em = em;
this.outerEm = em / jax.HTMLCSS.scale; this.outerEm = em / jax.HTMLCSS.scale;
emex.parentNode.removeChild(emex); emex.parentNode.removeChild(emex);
@ -1448,8 +1448,8 @@
min_rule_thickness: 1.25 // in pixels min_rule_thickness: 1.25 // in pixels
}, },
PLANE1: String.fromCharCode(0xD835), PLANE1: "\uD835",
NBSP: String.fromCharCode(0xA0), NBSP: "\u00A0",
rfuzz: 0 // adjustment to rule placements in roots rfuzz: 0 // adjustment to rule placements in roots
}); });