-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with scale with mtextInheritFont #3194
Comments
Yes, 4.0.0-beta.4 does not get the width of text correct when MathJax = {
output: {
linebreaks: {inline: false},
mtextInheritFont: true,
scale: 1.2
},
startup: {
ready() {
const {CHTML} = MathJax._.output.chtml_ts;
Object.assign(CHTML.prototype, {
_unknownText: CHTML.prototype.unknownText,
unknownText(text, variant, width = null, rscale = 1) {
const node = this._unknownText(text, variant, width, rscale);
if (width !== null) {
this.adaptor.setStyle(node, 'width', this.fixed(width * this.math.metrics.scale * rscale) + 'em');
}
return node;
},
measureTextNode(textNode) {
const adaptor = this.adaptor;
const text = adaptor.clone(textNode);
adaptor.setStyle(text, 'font-family', adaptor.getStyle(text, 'font-family').replace(/MJXZERO, /g, ''));
const em = this.math.metrics.em;
const style = {
position: 'absolute', top: 0, left: 0,
'white-space': 'nowrap',
'font-size': this.fixed(em, 3) + 'px'
};
const node = this.html('mjx-measure-text', {style}, [text]);
adaptor.append(adaptor.parent(this.math.start.node), this.container);
adaptor.append(this.container, node);
let w = adaptor.nodeSize(text, em)[0];
adaptor.remove(this.container);
adaptor.remove(node);
return {w: w, h: .75, d: .2};
}
});
MathJax.startup.defaultReady();
}
}
} as a work-around until beta.5 is released. |
I should point out that there are a number of issues with your MathJax configuration. You seem to be mixing v2 options with the v3/v4 configuration, and other options are out of place. For example, extensions: ["mml2jax.js", "MathMenu.js", "MathZoom.js"],
MathML: {
extensions: ["mml3.js"]
}, are v2 options, and have not effect in v3/v4. It is also a bit odd to set The options mtextFont: 'fontRegular',
...
linebreaks: {
inline: !0,
width: "100%",
lineleading: 2,
LinebreakVisitor: null
}, are in the wrong place, as they should be in the The option mtextFontSize: 15, doesn't exist, so has no effect. The options includeHtmlTags: {
br: "\n",
wbr: "",
"#comment": ""
},
ignoreHtmlClass: "tex2jax_ignore",
processHtmlClass: "tex2jax_process", all belong in the Since you are using MathML input, not TeX, the block tex: {
inlineMath: [["$", "$"]],
processEscapes: !1
}, is superfluous, unless you are using TeX notation elsewhere. And the As for load: ["[tex]/tagformat", "output/chtml"], you are loading the Finally, in chtml: {
displayAlign: 'right',
scale: 1.2,
minScale: .75,
mtextInheritFont: !0,
merrorInheritFont: !0,
skipAttributes: {},
exFactor: 18,
displayAlign: "center",
displayIndent: "0",
matchFontHeight: 0,
adaptiveCSS: !0
}, you have specified The So a minimal configuration that is equivalent to the one you have would be: window.MathJax = {
options: {
enableMenu: !1
},
loader: {
paths: {
"mathjax-modern": "https://cdn.chista.me/chista-mathjax-4.0.0-beta.4/mathjax-modern-font"
}
},
chtml: {
displayAlign: 'right',
scale: 1.2,
mtextInheritFont: !0,
merrorInheritFont: !0,
matchFontHeight: 0
},
startup: {
ready() {
const t = MathJax._.input.tex.ParseMethods.default,
{ RegExpMap: a } = MathJax._.input.tex.TokenMap;
new a("digit", t.digit, /[\d.٫۰-۹]/);
const { ChtmlMn: e } = MathJax._.output.chtml.Wrappers.mn;
e.prototype.remapChars = function (t) {
const a = [];
for (const e of t) {
const t = this.font.getRemappedChar("mn", e);
a.push(...(t ? this.unicodeChars(t, this.variant) : [e]));
}
return a;
};
const { FontData: n } = MathJax._.output.common.FontData,
o = n.defaultMnMap;
for (var s = 0; s < 10; s++) o[48 + s] = String.fromCodePoint(1776 + s);
MathJax.startup.defaultReady();
}
}
}); |
One of the reasons you have run into this width issue is that your re using <mtext>f(x)</mtext> should be <mi>f</mi>
<mrow>
<mo>(<mo>
<mi>x</mi>
<mo>)</mo>
</mrow> If you put everything into Since the width issue only affect |
If you don't use
I'm using code for persian digit: const t = MathJax._.input.tex.ParseMethods.default,
{ RegExpMap: a } = MathJax._.input.tex.TokenMap;
new a("digit", t.digit, /[\d.٫۰-۹]/);
const { ChtmlMn: e } = MathJax._.output.chtml.Wrappers.mn;
e.prototype.remapChars = function (t) {
const a = [];
for (const e of t) {
const t = this.font.getRemappedChar("mn", e);
a.push(...(t ? this.unicodeChars(t, this.variant) : [e]));
}
return a;
};
const { FontData: n } = MathJax._.output.common.FontData,
o = n.defaultMnMap;
for (var s = 0; s < 10; s++) o[48 + s] = String.fromCodePoint(1776 + s); Since you aren't using TeX input (you are using const t = MathJax._.input.tex.ParseMethods.default,
{ RegExpMap: a } = MathJax._.input.tex.TokenMap;
new a("digit", t.digit, /[\d.٫۰-۹]/); since they are for TeX, and aren't needed for MathML. That will avoid the error without having to load the |
I fixed the small problem of displaying indices in the formulas according to what you said
using mml-chtml.js |
Can you provide a screen shot for the following expression: <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<msub>
<mtext>A</mtext>
<mtext>A</mtext>
</msub>
<msub>
<mi mathvariant="normal">A</mi>
<mi mathvariant="normal">A</mi>
</msub>
<msub>
<mtext>p</mtext>
<mtext>p</mtext>
</msub>
<msub>
<mi mathvariant="normal">p</mi>
<mi mathvariant="normal">p</mi>
</msub>
</math> Thanks. Also, it is best to open a new issue rather than reopen an old one, when you have a new problem to report. |
Yes, sure, I thought it would be better this way, I apologize |
|
Thanks for the screen shot. It looks like something in your MathJax configuration or CSS is preventing subscripts from being reduced in size. At one point, I gave you code for changing the Do you have any CSS that is intended to affect MathJax output, and if so, what is it? Does your browser have a minimum font size setting, and if so, what is it? In the past, the subscripts where properly sized (see your screen shots in #3176, for example), so something you have changed since then is causing this. |
That is what is causing the problem. The
I agree, but that is what you have requested by setting
I don't know if the images you presented are for Setting |
Thank you very much for your explanation |
For h = 1 it is not good in my opinion |
I set these settings and sent you a screenshot startup: {
ready() {
const { ChtmlMn: e } = MathJax._.output.chtml.Wrappers.mn;
e.prototype.remapChars = function (t) {
const a = [];
for (const e of t) {
const t = this.font.getRemappedChar("mn", e);
a.push(...(t ? this.unicodeChars(t, this.variant) : [e]));
}
return a;
};
const { FontData: n } = MathJax._.output.common.FontData,
o = n.defaultMnMap;
for (var s = 0; s < 10; s++) o[48 + s] = String.fromCodePoint(1776 + s);
const { CHTML } = MathJax._.output.chtml_ts;
Object.assign(CHTML.prototype, {
_unknownText: CHTML.prototype.unknownText,
unknownText(text, variant, width = null, rscale = 1) {
const node = this._unknownText(text, variant, width, rscale);
if (width !== null) {
this.adaptor.setStyle(node, 'width', this.fixed(width * this.math.metrics.scale * rscale) + 'em');
}
return node;
},
measureTextNode(textNode) {
const adaptor = this.adaptor;
const text = adaptor.clone(textNode);
adaptor.setStyle(text, 'font-family', adaptor.getStyle(text, 'font-family').replace(/MJXZERO, /g, ''));
const em = this.math.metrics.em;
const style = {
position: 'absolute', top: 0, left: 0,
'white-space': 'nowrap',
'font-size': this.fixed(em, 3) + 'px'
};
const node = this.html('mjx-measure-text', { style }, [text]);
adaptor.append(adaptor.parent(this.math.start.node), this.container);
adaptor.append(this.container, node);
let w = adaptor.nodeSize(text, em)[0];
adaptor.remove(this.container);
adaptor.remove(node);
return { w: w, h: .85, d: .15 };
}
});
const { MmlMath } = MathJax._.core.MmlTree.MmlNodes.math;
const { MmlMstyle } = MathJax._.core.MmlTree.MmlNodes.mstyle;
MmlMath.defaults.scriptsizemultiplier = MmlMstyle.defaults.scriptsizemultiplier = .875;
MathJax.startup.defaultReady();
const params = MathJax.startup.document.outputJax.font.params;
params.rule_thickness = .130;
params.rule_factor = .75;
},
}, |
const params = MathJax.startup.document.outputJax.font.params; params.rule_thickness = .130; params.rule_factor = .75; Yes, please see the comment where I gave you those changes. This was in response to your asking for more space between fraction lines and the numerator and denominator.
This is an error in the code I gave you. The this.adaptor.setStyle(node, 'width', this.fixed(width * this.math.metrics.scale * rscale) + 'em'); making it this.adaptor.setStyle(node, 'width', this.fixed(width * this.math.metrics.scale) + 'em'); instead.
The size of the subscripts are controlled by the If you don't want to make the subscripts smaller, there is another parameter that is used in determining how far down to put subscripts. If you set params.sub1 = .3; along with the changes to |
Correct width for unknown fonts in scaled text in CHTML (mathjax/MathJax#3194)
When I set the scale to 1.2 and mtextInheritFont = true, the formulas stick together
![Screenshot from 2024-02-24 16-01-23](https://private-user-images.githubusercontent.com/10929451/307520446-f3e2a813-a09c-4997-8b8f-8ba5d163afb1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3NzE5MzUsIm5iZiI6MTcxOTc3MTYzNSwicGF0aCI6Ii8xMDkyOTQ1MS8zMDc1MjA0NDYtZjNlMmE4MTMtYTA5Yy00OTk3LThiOGYtOGJhNWQxNjNhZmIxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjMwVDE4MjAzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIxNmFmOGQzN2U3ZDNmNmNmYWMzZmJhOWM3YjM4ZTg0Y2JhZmMyNmI3OTkyMWM1NWQ2YmE1ZDkzYTRlZGQyZTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Np2YYsJj5krbPv4Vg8yP2OOviKLjD2p1GSu9V5ExkTE)
![Screenshot from 2024-02-24 16-00-48](https://private-user-images.githubusercontent.com/10929451/307520452-7ce32c75-4fa6-444c-ad70-eed84c054013.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3NzE5MzUsIm5iZiI6MTcxOTc3MTYzNSwicGF0aCI6Ii8xMDkyOTQ1MS8zMDc1MjA0NTItN2NlMzJjNzUtNGZhNi00NDRjLWFkNzAtZWVkODRjMDU0MDEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjMwVDE4MjAzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNlZjc1MDg5MTA1ZjhjZmZiNGM4MTM1NTkzMmIyNjc0MzRjMmIzM2E3MmQ3MDI2ZTI3ODFkZDQ1ZGMzYjgxMmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.QDCpABVmC1P9Cj2GEXaP-MakbOBKbGK8hdxYxRY9pkE)
mathjax version: 4.0.0-beta.4
using mml-chtml.js
mathjax config:
using iran-yekan persian font :
IRANYekanXFaNum-Regular.zip
exmple mml for image number 2:
The text was updated successfully, but these errors were encountered: