Skip to content

Commit 2de09d8

Browse files
committed
Add a check if defaultEm is zero, and retry after a delay if it is. WebKit seems to have this happen sometimes when web fonts are used for the page (though hard to reproduce). Resolves issue mathjax#576.
1 parent 2c5ecf6 commit 2de09d8

File tree

1 file changed

+17
-0
lines changed
  • unpacked/jax/output/HTML-CSS

1 file changed

+17
-0
lines changed

unpacked/jax/output/HTML-CSS/jax.js

+17
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,23 @@
450450
//
451451
InitializeHTML: function () {
452452
this.PreloadWebFonts();
453+
this.getDefaultExEm();
454+
//
455+
// If the defaultEm size is zero, it might be that a web font hasn't
456+
// arrived yet, so try to wait for it, but don't wait too long.
457+
//
458+
if (this.defaultEm) return;
459+
var ready = MathJax.Callback();
460+
AJAX.timer.start(AJAX,function (check) {
461+
if (check.time(ready)) {HUB.signal.Post("HTML-CSS Jax - no default em size"); return}
462+
HTMLCSS.getDefaultExEm();
463+
if (HTMLCSS.defaultEm) {ready()} else {setTimeout(check,check.delay)}
464+
},this.defaultEmDelay,this.defaultEmTimeout);
465+
return ready;
466+
},
467+
defaultEmDelay: 100, // initial delay when checking for defaultEm
468+
defaultEmTimeout: 1000, // when to stop looking for defaultEm
469+
getDefaultExEm: function () {
453470
//
454471
// Get the default sizes (need styles in place to do this)
455472
//

0 commit comments

Comments
 (0)