以下配置似乎實現所需的回退鏈 (在我的有限測試中)。
<script type="text/javascript"
src="../MathJax-2.7.1/MathJax.js?config=TeX-AMS-MML_SVG">
</script>
<script type="text/x-mathjax-config">
//
// - Mathjax config to implement the following fallback chain:
//
// 1. HTML-CSS webFont ("STIX-Web")
// 2. SVG ("STIX-Web")
// 3. Other fallback fonts (local generic, image, etc)
//
// - Change availableFonts to ["STIX"] and preferredFont to "STIX"
// to allow local STIX fonts. Implements the fallback chain below:
//
// 1. HTML-CSS local ("STIX")
// 2. HTML-CSS webFont ("STIX-Web")
// 3. SVG ("STIX-Web")
// 4. Other fallback fonts (local generic, image, etc)
//
//
// Use STIX font consistently across HTML-CSS and SVG
//
MathJax.Hub.Config({
jax: ["input/TeX", "input/MathML",
"output/HTML-CSS", "output/SVG", "output/PreviewHTML"
],
"HTML-CSS": {
imageFont: null,
webFont: "STIX-Web",
availableFonts: [], // Or: ["STIX"], to allow local
preferredFont: null // Or: "STIX", to allow local
},
"SVG": {
font: "STIX-Web"
}
});
MathJax.Hub.Register.StartupHook("End Jax", function() {
// 1. Set HTML-CSS as the initially preferred output processor.
// (Temporarily overrides the renderer value set by MathMenu
// without affecting the user's chosen renderer elsewhere.)
var jax = "HTML-CSS";
MathJax.Hub.setRenderer(jax);
// 2. Install callback which switches renderer to SVG if HTML-CSS fails.
var nopast = true;
MathJax.Hub.Startup.signal.Interest(QueSVGfallback, nopast);
});
</script>
<script>
//
// This callback (when installed) scans through messages to check
// (as in FontWarnings.js) if HTML-CSS font loading has failed.
// If so, it queues a request to switch to SVG rendering.
//
var QueSVGfallback = (function() { // Anonymous "closure" to keep quecount
var quecount = 0;
return function(m) { // The real callback function
if (quecount > 0) return; // Prevent multiple queueing
m = m + "";
if (m.match(/HTML-CSS Jax - /)) {
if (m.match(/- using image fonts/) ||
m.match(/- no valid font/) ||
m.match(/- disable web fonts/)) {
MathJax.Hub.Queue(
["setRenderer", MathJax.Hub, "SVG", "jax/mml"],
["Rerender", MathJax.Hub]
);
quecount++;
}
}
}
})();
</script>
我想弄清楚,這是一個_SERVER side_問題:如何在我的網頁配置mathjax讓我的網頁瀏覽者看到上面的後備行爲? – GDGP