本文介绍了确保字体在未测试的机器上用于MathJax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站的样式表中,我有

  .mi,.mo {
font-family:宪章,MathJax_Math!
}

暂时搁置这是否会为用户总是产生满意的结果理想的版本的宪章是存在的(迄今为止它为我),有一种方法,以确保这将有相同的效果,我不能测试它的机器。显然,这对于缺乏宪章的用户来说可以优雅地失败,但我不知道是否有Charters广泛使用,缺乏使我的版本工作的功能。



是否有版本的Charter更好或更差的渲染MathJax?如果是这样,如何定位和测试它们,或者排除能力较差的版本?






注意这不是关于与页面一起下载Charter的问题。如果用户没有Charter,他可能不会附加它,并且会与MathJax的默认字体很好。我想确定的是,拥有Charter的用户获得MathJax作为宪章,但是有穷章(如果他们存在)的用户不受惩罚。

解决方案

MathJax目前不支持类似宪章的字体。



MathJax只支持有限数量的字体,无论是webfont还是本地安装; ,但是IIRC宪章不包含许多数学字符 - 因此渲染质量将再次下降。



最后,如果您只需要在数学内容中使用文本框就可以使用Charter,这是实际支持的。只需配置MathJax通过设置 mtextFontInherit = true 来为文本框使用周围的字体。


In the stylesheet for my website I have

.mi, .mo {
    font-family: 'Charter', 'MathJax_Math' !important;
}

Setting aside for the moment whether this will always produce satisfactory results for users when an ideal version of Charter is present (so far it does for me), is there a way to ensure that this will have the same effect on machines that I can't test it on. Clearly this fails gracefully for users that lack Charter entirely, but what I wonder is whether the there are Charters in wide use that lack the features that make my version work.

Are there versions of Charter that are better or worse for rendering MathJax? If so how can a locate and test them, or perhaps exclude versions that are less capable?


Note this is not a question about downloading Charter along with the pages. If a user doesn't have Charter, he probably isn't attached to it and will be fine with MathJax's default font. What I want to be sure of is that a user who has Charter gets MathJax as Charter, but that users with "poor" Charters (if they exist) aren't punished.

解决方案

No Charter-like font is currently supported by MathJax.

MathJax only supports a limited number of fonts, no matter if webfont or locally installed; see the docs (under availableFonts and webFont)

While you can override fonts using !important, this will lead to poor typesetting quality. Due to browser limitations, MathJax can not access the relevant metrics of the font to correctly calculate its layout. For a supported font, MathJax will load pre-compiled font data dynamically.

Of course you can add support for Charter to MathJax using the MathJax development tools, but IIRC Charter does not contain many mathematical characters -- so rendering quality will be poor again.

Finally, if you only need text boxes within mathematical content to use Charter, that is actually supported. Just configure MathJax to use the surrounding font for text boxes by setting mtextFontInherit = true.

这篇关于确保字体在未测试的机器上用于MathJax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 12:05