Fix annotation-xml to use correct scaling (now that that has changed)
This commit is contained in:
parent
5394ea5b68
commit
604c09f9ca
|
@ -12,5 +12,5 @@
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function(){var c="1.1";var a=MathJax.ElementJax.mml,d=MathJax.OutputJax.SVG;var b=d.BBOX;b.FOREIGN=b.Subclass({type:"foreignObject",removeable:false});a["annotation-xml"].Augment({toSVG:function(){var f=this.SVG();this.SVGhandleSpace(f);var h=this.Get("encoding");for(var g=0,e=this.data.length;g<e;g++){f.Add(this.data[g].toSVG(h),f.w,0)}f.Clean();this.SVGhandleColor(f);this.SVGsaveData(f);return f}});a.xml.Augment({toSVG:function(e){var q=d.textSVG.parentNode;d.mathDiv.style.width="auto";var k=Math.floor(100*100/d.scale);this.div.style.fontSize=k+"%";q.insertBefore(this.div,d.textSVG);var r=this.div.offsetWidth,n=this.div.offsetHeight;var p=MathJax.HTML.addElement(this.div,"span",{style:{display:"inline-block",overflow:"hidden",height:n+"px",width:"1px",marginRight:"-1px"}});var o=this.div.offsetHeight-n;n-=o;this.div.removeChild(p);q.removeChild(this.div);d.mathDiv.style.width=0;var g=1000/d.em/(d.scale/100);var l=b.FOREIGN({y:(-n)+"px",width:r+"px",height:(n+o)+"px",style:"font-size:"+k+"%",transform:"scale("+g+") matrix(1 0 0 -1 0 0)"});for(var j=0,f=this.data.length;j<f;j++){l.element.appendChild(this.data[j].cloneNode(true))}l.w=r*g;l.h=n*g;l.d=o*g;l.Clean();this.SVGsaveData(l);return l}});MathJax.Hub.Startup.signal.Post("SVG annotation-xml Ready");MathJax.Ajax.loadComplete(d.autoloadDir+"/annotation-xml.js")});
|
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function(){var c="1.1";var a=MathJax.ElementJax.mml,d=MathJax.OutputJax.SVG;var b=d.BBOX;b.FOREIGN=b.Subclass({type:"foreignObject",removeable:false});a["annotation-xml"].Augment({toSVG:function(){var f=this.SVG();this.SVGhandleSpace(f);var h=this.Get("encoding");for(var g=0,e=this.data.length;g<e;g++){f.Add(this.data[g].toSVG(h),f.w,0)}f.Clean();this.SVGhandleColor(f);this.SVGsaveData(f);return f}});a.xml.Augment({toSVG:function(e){var p=d.textSVG.parentNode;d.mathDiv.style.width="auto";p.insertBefore(this.div,d.textSVG);var q=this.div.offsetWidth,k=this.div.offsetHeight;var o=MathJax.HTML.addElement(this.div,"span",{style:{display:"inline-block",overflow:"hidden",height:k+"px",width:"1px",marginRight:"-1px"}});var n=this.div.offsetHeight-k;k-=n;this.div.removeChild(o);p.removeChild(this.div);d.mathDiv.style.width="";var g=1000/d.em;var l=b.FOREIGN({y:(-k)+"px",width:q+"px",height:(k+n)+"px",transform:"scale("+g+") matrix(1 0 0 -1 0 0)"});for(var j=0,f=this.data.length;j<f;j++){l.element.appendChild(this.data[j].cloneNode(true))}l.w=q*g;l.h=k*g;l.d=n*g;l.r=l.w;l.l=0;l.Clean();this.SVGsaveData(l);return l}});MathJax.Hub.Startup.signal.Post("SVG annotation-xml Ready");MathJax.Ajax.loadComplete(d.autoloadDir+"/annotation-xml.js")});
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,6 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
|
||||||
//
|
//
|
||||||
var span = SVG.textSVG.parentNode;
|
var span = SVG.textSVG.parentNode;
|
||||||
SVG.mathDiv.style.width = "auto"; // Firefox returns offsetWidth = 0 without this
|
SVG.mathDiv.style.width = "auto"; // Firefox returns offsetWidth = 0 without this
|
||||||
var unscale = Math.floor(100*100/SVG.scale);
|
|
||||||
this.div.style.fontSize = unscale+"%";
|
|
||||||
span.insertBefore(this.div,SVG.textSVG);
|
span.insertBefore(this.div,SVG.textSVG);
|
||||||
var w = this.div.offsetWidth, h = this.div.offsetHeight;
|
var w = this.div.offsetWidth, h = this.div.offsetHeight;
|
||||||
var strut = MathJax.HTML.addElement(this.div,"span",{
|
var strut = MathJax.HTML.addElement(this.div,"span",{
|
||||||
|
@ -59,14 +57,13 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
|
||||||
});
|
});
|
||||||
var d = this.div.offsetHeight - h; h -= d;
|
var d = this.div.offsetHeight - h; h -= d;
|
||||||
this.div.removeChild(strut);
|
this.div.removeChild(strut);
|
||||||
span.removeChild(this.div); SVG.mathDiv.style.width = 0;
|
span.removeChild(this.div); SVG.mathDiv.style.width = "";
|
||||||
//
|
//
|
||||||
// Create foreignObject element for the content
|
// Create foreignObject element for the content
|
||||||
//
|
//
|
||||||
var scale = 1000/SVG.em/(SVG.scale/100);
|
var scale = 1000/SVG.em;
|
||||||
var svg = BBOX.FOREIGN({
|
var svg = BBOX.FOREIGN({
|
||||||
y:(-h)+"px", width:w+"px", height:(h+d)+"px",
|
y:(-h)+"px", width:w+"px", height:(h+d)+"px",
|
||||||
style:"font-size:"+unscale+"%", // font scales separately from other elements
|
|
||||||
transform:"scale("+scale+") matrix(1 0 0 -1 0 0)"
|
transform:"scale("+scale+") matrix(1 0 0 -1 0 0)"
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
|
@ -78,6 +75,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
|
||||||
// Set the scale and finish up
|
// Set the scale and finish up
|
||||||
//
|
//
|
||||||
svg.w = w*scale; svg.h = h*scale; svg.d = d*scale;
|
svg.w = w*scale; svg.h = h*scale; svg.d = d*scale;
|
||||||
|
svg.r = svg.w; svg.l = 0;
|
||||||
svg.Clean();
|
svg.Clean();
|
||||||
this.SVGsaveData(svg);
|
this.SVGsaveData(svg);
|
||||||
return svg;
|
return svg;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user