Add config option for matching font heights in NativeMML and HTML-CSS output (can't do it for SVG, since we aren't using native fonts)
This commit is contained in:
parent
bbf543a840
commit
c05ab62ecc
|
@ -35,6 +35,7 @@ MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
|
||||||
webfontDir: MathJax.OutputJax.fontDir + "/HTML-CSS", // font name added later
|
webfontDir: MathJax.OutputJax.fontDir + "/HTML-CSS", // font name added later
|
||||||
|
|
||||||
config: {
|
config: {
|
||||||
|
matchFontHeight: true, // try to match math font height to surrounding font?
|
||||||
scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor
|
scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor
|
||||||
availableFonts: ["STIX","TeX"], // list of local fonts to check for
|
availableFonts: ["STIX","TeX"], // list of local fonts to check for
|
||||||
preferredFont: "TeX", // preferred local font (TeX or STIX)
|
preferredFont: "TeX", // preferred local font (TeX or STIX)
|
||||||
|
|
|
@ -534,7 +534,8 @@
|
||||||
ex = this.defaultEx; em = this.defaultEm;
|
ex = this.defaultEx; em = this.defaultEm;
|
||||||
if (relwidth) {maxwidth = this.defaultWidth}
|
if (relwidth) {maxwidth = this.defaultWidth}
|
||||||
}
|
}
|
||||||
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,(ex/this.TeX.x_height)/em) * this.config.scale);
|
scale = (this.config.matchFontHeight ? ex/this.TeX.x_height/em : 1);
|
||||||
|
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale)*this.config.scale);
|
||||||
jax.HTMLCSS.scale = scale/100; jax.HTMLCSS.fontSize = scale+"%";
|
jax.HTMLCSS.scale = scale/100; jax.HTMLCSS.fontSize = scale+"%";
|
||||||
jax.HTMLCSS.em = jax.HTMLCSS.outerEm = em; this.em = em * scale/100; jax.HTMLCSS.ex = ex;
|
jax.HTMLCSS.em = jax.HTMLCSS.outerEm = em; this.em = em * scale/100; jax.HTMLCSS.ex = ex;
|
||||||
jax.HTMLCSS.lineWidth = (linebreak ? this.length2em(width,1,maxwidth/this.em) : 1000000);
|
jax.HTMLCSS.lineWidth = (linebreak ? this.length2em(width,1,maxwidth/this.em) : 1000000);
|
||||||
|
@ -584,7 +585,7 @@
|
||||||
this.em = MML.mbase.prototype.em = jax.HTMLCSS.em * jax.HTMLCSS.scale;
|
this.em = MML.mbase.prototype.em = jax.HTMLCSS.em * jax.HTMLCSS.scale;
|
||||||
this.outerEm = jax.HTMLCSS.em; this.scale = jax.HTMLCSS.scale;
|
this.outerEm = jax.HTMLCSS.em; this.scale = jax.HTMLCSS.scale;
|
||||||
this.linebreakWidth = jax.HTMLCSS.lineWidth;
|
this.linebreakWidth = jax.HTMLCSS.lineWidth;
|
||||||
span.style.fontSize = jax.HTMLCSS.fontSize;
|
if (this.scale !== 1) {span.style.fontSize = jax.HTMLCSS.fontSize}
|
||||||
//
|
//
|
||||||
// Typeset the math
|
// Typeset the math
|
||||||
//
|
//
|
||||||
|
|
|
@ -32,6 +32,7 @@ MathJax.OutputJax.NativeMML = MathJax.OutputJax({
|
||||||
extensionDir: MathJax.OutputJax.extensionDir + "/NativeMML",
|
extensionDir: MathJax.OutputJax.extensionDir + "/NativeMML",
|
||||||
|
|
||||||
config: {
|
config: {
|
||||||
|
matchFontHeight: true, // try to match math font height to surrounding font?
|
||||||
scale: 100, // scaling factor for all math
|
scale: 100, // scaling factor for all math
|
||||||
minScaleAdjust: 50, // minimum scaling to adjust to surrounding text
|
minScaleAdjust: 50, // minimum scaling to adjust to surrounding text
|
||||||
// (since the code for that is a bit delicate)
|
// (since the code for that is a bit delicate)
|
||||||
|
|
|
@ -257,11 +257,12 @@
|
||||||
ex = test.firstChild.offsetWidth/60;
|
ex = test.firstChild.offsetWidth/60;
|
||||||
mex = test.lastChild.offsetWidth/60;
|
mex = test.lastChild.offsetWidth/60;
|
||||||
if (ex === 0 || ex === "NaN") {ex = this.defaultEx; mex = this.defaultMEx}
|
if (ex === 0 || ex === "NaN") {ex = this.defaultEx; mex = this.defaultMEx}
|
||||||
scale = (mex > 1 ? ex/mex : 1) * this.config.scale;
|
scale = (this.config.matchFontHeight && mex > 1 ? ex/mex : 1);
|
||||||
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale));
|
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale) * this.config.scale);
|
||||||
jax.NativeMML.ex = ex; jax.NativeMML.scale = scale/100;
|
jax.NativeMML.ex = ex;
|
||||||
} else {scale = 100}
|
} else {scale = 100}
|
||||||
jax.NativeMML.fontSize = scale+"%";
|
jax.NativeMML.fontSize = scale+"%";
|
||||||
|
jax.NativeMML.scale = scale/100;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Remove the test spans used for determining scales
|
// Remove the test spans used for determining scales
|
||||||
|
@ -286,9 +287,9 @@
|
||||||
var jax = script.MathJax.elementJax, math = jax.root;
|
var jax = script.MathJax.elementJax, math = jax.root;
|
||||||
var span = document.getElementById(jax.inputID+"-Frame"),
|
var span = document.getElementById(jax.inputID+"-Frame"),
|
||||||
container = span.firstChild, mspan = container.firstChild;
|
container = span.firstChild, mspan = container.firstChild;
|
||||||
span.style.fontSize = jax.NativeMML.fontSize;
|
|
||||||
this.ex = jax.NativeMML.ex || this.defaultEx;
|
this.ex = jax.NativeMML.ex || this.defaultEx;
|
||||||
this.scale = jax.NativeMML.scale || 1;
|
this.scale = jax.NativeMML.scale || 1;
|
||||||
|
if (this.scale !== 1) {span.style.fontSize = jax.NativeMML.fontSize}
|
||||||
//
|
//
|
||||||
// Convert to MathML (if restarted, remove any partial math)
|
// Convert to MathML (if restarted, remove any partial math)
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue
Block a user