-
Notifications
You must be signed in to change notification settings - Fork 207
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
Allow to disable font loading from an URL. (mathjax/MathJax#2539) #554
Allow to disable font loading from an URL. (mathjax/MathJax#2539) #554
Conversation
@dpvc I'm willing to implement an alternative solution if you think that my proposal is not acceptable. Or maybe there's another way to disable |
I know it has been a long time responding to this, and I apologize for that. Things never seem to get any less busy these days. One reason for the delay is that I have concerns about the PR, and wasn't sure how to voice them properly. My main issue with this is that I am hesitant to provide a configuration option that would essentially break MathJax output unless you made a fairly sophisticated setup externally. That is, unless you provide the CSS for the fonts yourself in some way, MathJax's output would be broken. This seems like a dangerous outcome for a simple configuration setting, especially when the use-case is relatively limited. I think there is a more appropriate way to handle this, which is to override the For example, MathJax = {
startup: {
ready() {
const {CHTMLFontData} = MathJax._.output.chtml.FontData;
CHTMLFontData.prototype.addFontURLs = () => {};
MathJax.startup.defaultReady();
}
}
} would disable the generation of MathJax = {
startup: {
ready() {
const {CHTMLFontData} = MathJax._.output.chtml.FontData;
const addFontURLs = CHTMLFontData.prototype.addFontURLs;
CHTMLFontData.prototype.addFontURLs = (styles, fonts, url) => {
// add whatever CSS you need to the style obejct.
// The fonts variable is the original @font-face definitions
// with %%URL%% where the URL shoud go which is in the url
// argument. You can change the fonts in any way that you
// need, or ignore them entirely.
// See
//
// https://github.com/mathjax/MathJax-src/blob/2dd53ce6c8af3c9cceba0baf014ea9b065130774/ts/output/chtml/FontData.ts#L217-L223
//
// for the original code.
//
if (url !== false) {
addFontURLs.call(this, styles, fonts, url);
}
}
MathJax.startup.defaultReady();
}
}
} where you use I'm sorry it has taken me so long to write this up for you. It has been guilting me in my inbox for quite a while, and I know you have been waiting a long time. |
PS, for example, the second configuration above could be used to replace the src for the fonts with data URLs. |
Hey @dpvc, no worries, you don't need to apologize. I'm extremely grateful for all the work you've done and the time you took to help me with a detailed explanation 🤗
I didn't know I could do that and I completely agree that this is a better solution 👍🏻
Just to be clear, it's currently possible to override the
That sounds good, I will give it a try, thanks again for your time 🙌🏻 |
Thank you; you are very kind. I have been feeling bad about this PR for some time, and am glad to have finally been able to give you some feedback.
It is possible to subclass it, but you can't currently tell the CHTML output jax to use the subclass (it always uses the But again, in the next feature release, you will be able to use a proper subclass. |
Given that, I'm going to close this PR, then. Thanks for the willingness to contribute! |
@dpvc does mathjax now support this feature, or is there any work around to this |
Not directly.
I gave two mechanisms that could be used to handle it in the comments above. The second one allows you to configure |
resolves mathjax/MathJax#2539