Skip to content

Commit 2755cbd

Browse files
committed
Make web font loop into an extension (first draft)
1 parent c9766d4 commit 2755cbd

File tree

5 files changed

+0
-182
lines changed

5 files changed

+0
-182
lines changed

unpacked/MathJax.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,10 +1741,6 @@ MathJax.Hub = {
17411741
showMathMenuMSIE: true, // separtely determine if MSIE should have math menu
17421742
// (since the code for that is a bit delicate)
17431743

1744-
matchWebFonts: false, // true means look for web fonts that may cause changes in the
1745-
// scaling factors for the math (off by default since it
1746-
// uses a loop every time math is rendered).
1747-
17481744
menuSettings: {
17491745
zoom: "None", // when to do MathZoom
17501746
CTRL: false, // require CTRL for MathZoom?

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
4444
undefinedFamily: "STIXGeneral,'Arial Unicode MS',serif", // fonts to use for unknown unicode characters
4545
mtextFontInherit: false, // to make <mtext> be in page font rather than MathJax font
4646

47-
fontCheckDelay: 500, // initial delay for the first check for web fonts
48-
// (set to null to prevent the checks)
49-
fontCheckTimeout: 15 * 1000, // how long to keep looking for font changes (15 seconds)
50-
5147
EqnChunk: (MathJax.Hub.Browser.isMobile ? 10: 50),
5248
// number of equations to process before showing them
5349
EqnChunkFactor: 1.5, // chunk size is multiplied by this after each chunk

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

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -627,16 +627,6 @@
627627

628628
postTranslate: function (state,partial) {
629629
var scripts = state.jax[this.id];
630-
if (!partial && HUB.config.matchWebFonts && this.config.matchFontHeight) {
631-
//
632-
// Check for changes in the web fonts that might affect the font
633-
// size for math elements. This is a periodic check that goes on
634-
// until a timeout is reached.
635-
//
636-
AJAX.timer.start(AJAX,["checkFonts",this,state.jax[this.id]],
637-
this.config.fontCheckDelay,this.config.fontCheckTimeout);
638-
639-
}
640630
if (!this.hideProcessedMath) return;
641631
//
642632
// Reveal this chunk of math
@@ -671,57 +661,6 @@
671661
state.HTMLCSSlast = state.HTMLCSSeqn;
672662
},
673663

674-
checkFonts: function (check,scripts) {
675-
if (check.time(function () {})) return;
676-
var size = [], i, m;
677-
//
678-
// Add the elements used for testing ex and em sizes
679-
//
680-
for (i = 0, m = scripts.length; i < m; i++) {
681-
script = scripts[i];
682-
if (script.parentNode && script.MathJax.elementJax) {
683-
script.parentNode.insertBefore(this.EmExSpan.cloneNode(true),script);
684-
}
685-
}
686-
//
687-
// Check to see if anything has changed
688-
//
689-
for (i = 0, m = scripts.length; i < m; i++) {
690-
script = scripts[i]; if (!script.parentNode) continue;
691-
var jax = script.MathJax.elementJax; if (!jax) continue;
692-
var span = document.getElementById(jax.inputID+"-Frame");
693-
//
694-
// Check if ex or mex has changed
695-
//
696-
var test = script.previousSibling, div = test.previousSibling;
697-
var ex = test.firstChild.offsetHeight/60;
698-
var em = test.lastChild.lastChild.offsetHeight/60;
699-
if (ex === 0 || ex === "NaN") {ex = this.defaultEx; em = this.defaultEm}
700-
if (ex !== jax.HTMLCSS.ex || em !== jax.HTMLCSS.em) {
701-
var scale = ex/this.TeX.x_height/em;
702-
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale)*this.config.scale);
703-
if (scale/100 !== jax.scale) {size.push(script); scripts[i] = {}}
704-
}
705-
}
706-
//
707-
// Remove markers
708-
//
709-
for (i = 0, m = scripts.length; i < m; i++) {
710-
script = scripts[i];
711-
if (script.parentNode && script.MathJax.elementJax) {
712-
script.parentNode.removeChild(script.previousSibling);
713-
}
714-
}
715-
//
716-
// Rerender the changed items
717-
//
718-
if (size.length) {MathJax.Hub.Queue(["Rerender",MathJax.Hub,[size],{}])}
719-
//
720-
// Try again later
721-
//
722-
setTimeout(check,check.delay);
723-
},
724-
725664
getJaxFromMath: function (math) {
726665
if (math.parentNode.className === "MathJax_Display") {math = math.parentNode}
727666
do {math = math.nextSibling} while (math && math.nodeName.toLowerCase() !== "script");

unpacked/jax/output/NativeMML/config.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ MathJax.OutputJax.NativeMML = MathJax.OutputJax({
3737
minScaleAdjust: 50, // minimum scaling to adjust to surrounding text
3838
// (since the code for that is a bit delicate)
3939

40-
fontCheckDelay: 500, // initial delay for the first width check for web fonts
41-
// (set to null to prevent the width checks)
42-
fontCheckTimeout: 15 * 1000, // how long to keep looking for width changes (15 seconds)
43-
4440
styles: {
4541
"DIV.MathJax_MathML": {
4642
"text-align": "center",

unpacked/jax/output/NativeMML/jax.js

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,6 @@
327327
},
328328

329329
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-
}
339330
if (this.forceReflow) {
340331
//
341332
// Firefox messes up some mtable's when they are dynamically created
@@ -346,106 +337,6 @@
346337
}
347338
},
348339

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-
449340
//
450341
// Remove MathML preceeding the script
451342
//

0 commit comments

Comments
 (0)