MathJax_Font_Test breaks responsive layouts in mobile browsers #681

Closed
opened this issue Dec 1, 2013 · 10 comments

Projects
None yet
4 participants

zohooo commented Dec 1, 2013

 MathJax adds a MathJax_Font_Test div into the body element when typesetting math formulas. Sometimes this div is too wide that it breaks responsive layouts, and add extra spaces to the web pages in mobile browsers. In my case, I add viewport meta tag to the head of the html file   This makes my web page occupy the whole width of the browser. But when MathJax starts to typeset some formulas in this page, such as $\xi\in(a,b),f'(\xi)=0$  It inserts a div of size 431px by 59px as follows:   At present, most of the mobile phones have device widths between 320px and 360px, therefore this div makes browsers add extra spaces to the page. In desktop browsers, I could solve this problem by adding "overflow: hidden" to body element. But this way is not working in mobile browsers.
Member

pkra commented Dec 1, 2013

 Thanks for reporting this. Do you have a minimal live example to demonstrate what goes wrong (on which systems)?
Author

zohooo commented Dec 3, 2013

 In android 4.1, I have tested the stock browser, mobile firefox and mobile chrome with the following web page:  MathJax Font Test
$$\xi\in(a,b),f'(\xi)=0$$
 You could see extra spaces in the right when draging the web page.
Author

zohooo commented Dec 3, 2013

 I'm wondering why we need so many characters MATHJAX AMS ˆ  in MathJax_Font_Test div?
Member

pkra commented Dec 4, 2013

 Thanks for the example. I can reproduce the problem on Android 4.3 with the stock browser. This also happens on Chrome for Android (though less pronounced). @dpvc is this expected behavior?
Member

pkra commented Dec 4, 2013

 Also confirmed on mobile Firefox for Android.
Member

dpvc commented Dec 4, 2013

 is this expected behavior? It is something we know about, and it is working as it "should" based on the current font test mechanism, so in that sense, "yes". But it would be good to be able to avoid the problem. I suspect that one solution would be to clear the font test div after it is used, so that the long string isn't left in place, and the content size would not be excessively long. That is probably easiest. We ran into this some time ago and I suggested to the user at the time to alter the font sizes used for the test (which apparently worked for him). It might be that we could do that, either conditionally for mobile devices, or if the width of the page is small, or by some other condition. In any case, I think it can be fixed, and could be included in the bug fix release that we are planning. @zohooo, the reason that the string is so long is that it helps to have more characters involved in order to be able to detect the difference in width that indicates the presence of the font. The font detection is delicate, and longer strings help make it more reliable.

Closed

worldnamer commented Dec 20, 2013

 Hey there. Any news about when this might happen? I just put something like this into our page. It seems to at least clean up the problem, but it'd be nice to be able to remove the code at some point. remove_div = function() { div = \$("#MathJax_Font_Test"); if (div.length > 0) { div.remove(); } else { console.log("cannot find mathjax font div"); } } MathJax.Hub.Startup.signal.Interest(function(message) { if (message == "HTML-CSS Jax - Web-Font TeX/Main/Regular") { MathJax.Hub.Queue(remove_div); } }); 

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 6, 2014

 Clear font test div so that its width doesn't affect the page size. r… 
…esolves issue mathjax#681.
 6c50f1d 

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 7, 2014

 Merge branch 'issue681' into develop. Issue mathjax#681. 
 76a4ee3 

Member

dpvc commented Feb 7, 2014

 => Merged

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 8, 2014

 Fixed accidental switching of true and false when testing for local f… 
…ont. Issue mathjax#681.
 ba238a6 

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 8, 2014

 Merge branch 'issue681' into develop. Issue mathjax#681. 
 2afb801 

Member

dpvc commented Apr 22, 2014

 I can't come up with a test case for this on one of the browsers we use in the test framework, so I'm marking it "do not write test case".

Member

 +1