|
327 | 327 | },
|
328 | 328 |
|
329 | 329 | postTranslate: function (state) {
|
330 |
| - if (!isMSIE && HUB.config.matchWebFonts) { |
331 |
| - // |
332 |
| - // Check for changes in the web fonts that might affect the sizes |
333 |
| - // of math elements. This is a periodic check that goes on until |
334 |
| - // a timeout is reached. |
335 |
| - // |
336 |
| - AJAX.timer.start(AJAX,["checkFonts",this,state.jax[this.id]], |
337 |
| - this.config.fontCheckDelay,this.config.fontCheckTimeout); |
338 |
| - } |
339 | 330 | if (this.forceReflow) {
|
340 | 331 | //
|
341 | 332 | // Firefox messes up some mtable's when they are dynamically created
|
|
346 | 337 | }
|
347 | 338 | },
|
348 | 339 |
|
349 |
| - // |
350 |
| - // Check to see if web fonts have been loaded that change the ex size |
351 |
| - // of the surrounding font, the ex size within the math, or the widths |
352 |
| - // of math elements. We do this by rechecking the ex and mex sizes |
353 |
| - // (to see if the font scaling needs adjusting) and by checking the |
354 |
| - // size of the inner mrow of math elements and mtd elements. The |
355 |
| - // sizes of these have been stored in the NativeMML object of the |
356 |
| - // element jax so that we can check for them here. |
357 |
| - // |
358 |
| - checkFonts: function (check,scripts) { |
359 |
| - if (check.time(function () {})) return; |
360 |
| - var adjust = [], mtd = [], size = [], i, m, script; |
361 |
| - // |
362 |
| - // Add the elements used for testing ex and em sizes |
363 |
| - // |
364 |
| - for (i = 0, m = scripts.length; i < m; i++) { |
365 |
| - script = scripts[i]; |
366 |
| - if (script.parentNode && script.MathJax.elementJax) { |
367 |
| - script.parentNode.insertBefore(this.EmExSpan.cloneNode(true),script); |
368 |
| - } |
369 |
| - } |
370 |
| - // |
371 |
| - // Check to see if anything has changed |
372 |
| - // |
373 |
| - for (i = 0, m = scripts.length; i < m; i++) { |
374 |
| - script = scripts[i]; if (!script.parentNode) continue; |
375 |
| - var jax = script.MathJax.elementJax; if (!jax) continue; |
376 |
| - var span = document.getElementById(jax.inputID+"-Frame"); |
377 |
| - var math = span.getElementsByTagName("math")[0]; if (!math) continue; |
378 |
| - jax = jax.NativeMML; |
379 |
| - // |
380 |
| - // Check if ex or mex has changed |
381 |
| - // |
382 |
| - var test = script.previousSibling; |
383 |
| - var ex = test.firstChild.offsetWidth/60; |
384 |
| - var mex = test.lastChild.offsetWidth/60; |
385 |
| - if (ex === 0 || ex === "NaN") {ex = this.defaultEx; mex = this.defaultMEx} |
386 |
| - var newEx = (ex !== jax.ex); |
387 |
| - if (newEx || mex != jax.mex) { |
388 |
| - var scale = (this.config.matchFontHeight && mex > 1 ? ex/mex : 1); |
389 |
| - scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale) * this.config.scale); |
390 |
| - if (scale/100 !== jax.scale) {size.push([span.style,scale])} |
391 |
| - jax.scale = scale/100; jax.fontScale = scale+"%"; jax.ex = ex; jax.mex = mex; |
392 |
| - } |
393 |
| - |
394 |
| - // |
395 |
| - // Check width of math elements |
396 |
| - // |
397 |
| - if ("scrollWidth" in jax && (newEx || jax.scrollWidth !== math.firstChild.scrollWidth)) { |
398 |
| - jax.scrollWidth = math.firstChild.scrollWidth; |
399 |
| - adjust.push([math.parentNode.style,jax.scrollWidth/jax.ex/jax.scale]); |
400 |
| - } |
401 |
| - // |
402 |
| - // Check widths of mtd elements |
403 |
| - // |
404 |
| - if (math.MathJaxMtds) { |
405 |
| - for (j = 0, n = math.MathJaxMtds.length; j < n; j++) { |
406 |
| - if (!math.MathJaxMtds[j].parentNode) continue; |
407 |
| - if (newEx || math.MathJaxMtds[j].firstChild.scrollWidth !== jax.mtds[j]) { |
408 |
| - jax.mtds[j] = math.MathJaxMtds[j].firstChild.scrollWidth; |
409 |
| - mtd.push([math.MathJaxMtds[j],jax.mtds[j]/jax.ex]); |
410 |
| - } |
411 |
| - } |
412 |
| - } |
413 |
| - } |
414 |
| - // |
415 |
| - // Remove markers |
416 |
| - // |
417 |
| - for (i = 0, m = scripts.length; i < m; i++) { |
418 |
| - script = scripts[i]; |
419 |
| - if (script.parentNode && script.MathJax.elementJax) { |
420 |
| - script.parentNode.removeChild(script.previousSibling); |
421 |
| - } |
422 |
| - } |
423 |
| - // |
424 |
| - // Adjust scaling factor |
425 |
| - // |
426 |
| - for (i = 0, m = size.length; i < m; i++) { |
427 |
| - size[i][0].fontSize = size[i][1] + "%"; |
428 |
| - } |
429 |
| - // |
430 |
| - // Adjust width of spans containing math elements that have changed |
431 |
| - // |
432 |
| - for (i = 0, m = adjust.length; i < m; i++) { |
433 |
| - adjust[i][0].width = adjust[i][1].toFixed(3)+"ex"; |
434 |
| - } |
435 |
| - // |
436 |
| - // Adjust widths of mtd elements that have changed |
437 |
| - // |
438 |
| - for (i = 0, m = mtd.length; i < m; i++) { |
439 |
| - var style = mtd[i][0].getAttribute("style"); |
440 |
| - style = style.replace(/(($|;)\s*min-width:).*?ex/,"$1 "+mtd[i][1].toFixed(3)+"ex"); |
441 |
| - mtd[i][0].setAttribute("style",style); |
442 |
| - } |
443 |
| - // |
444 |
| - // Try again later |
445 |
| - // |
446 |
| - setTimeout(check,check.delay); |
447 |
| - }, |
448 |
| - |
449 | 340 | //
|
450 | 341 | // Remove MathML preceeding the script
|
451 | 342 | //
|
|
0 commit comments