Closed Bug 701758 (mathjax-fonts) Opened 13 years ago Closed 12 years ago

Support for MathJax fonts

Categories

(Core :: MathML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: fredw, Assigned: fredw)

References

()

Details

(Keywords: dev-doc-complete)

Attachments

(3 files, 4 obsolete files)

Attached patch Experimental patch (obsolete) — Splinter Review
(In reply to Frédéric Wang from comment #3)
> MathJax also has its own Open Type fonts, which look closer to LaTeX fonts
> and thus are often preferred by MathJax users. That may be interesting to
> see if we can support them. They do not seem to contain an OpenType MATH
> table, though.

MathJax fonts can be downloaded with the command:

wget -r -np -nd http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/ -P MathJax-fonts/

The attached patch add support for token elements (other than mo). It also improves the rendering of mathvariant.
Comment on attachment 573836 [details] [diff] [review]
Experimental patch

I've started to add a converter from MathJax font table to our own format.

https://raw.github.com/fred-wang/MozillaCentralPatches/master/MathJax-fonts.diff
https://raw.github.com/fred-wang/MozillaCentralPatches/master/MathJax-fonts-2.diff
https://raw.github.com/fred-wang/MozillaCentralPatches/master/MathJax-fonts-3.diff

When I test on texvsmml.xhtml, symbols like sum seems to be read correctly from mathfontMathJax_Main.properties, but not other like parentheses or braces.
Attached patch Patch - part 2 (obsolete) — Splinter Review
I'm still not able to get the symbols built by parts used. I'm probably doing something wrong, but I can't see where the problem is.

When I use MathJax_Size4 as the base font instead of MathJax_Main, that seems to work. However, it looks like the definitions are taken from mathfontUnicode.properties.
Attachment #575831 - Flags: feedback?(karlt)
The horizontal braces are not currently included. The middle char needs to be drawn with 2 glyphs. I don't know if the code for composite char is still working?
Can you verify that mathfontMathJax_Main.properties is opened and read?
Perhaps the "_" might be getting filtered out somewhere.

(In reply to Frédéric Wang from comment #4)
> I don't know if the code for composite char is still working?

I'd guess not, but much of the code is still there, so it may not be too difficult to revive it.
OK, the problem was just that duplicate entries were generated for stretchy characters built by parts that also have variants. I've updated the patches.
Assignee: nobody → fred.wang
Attachment #573838 - Attachment is obsolete: true
Attachment #576433 - Attachment is patch: false
Attachment #576433 - Attachment mime type: text/plain → image/png
Attachment #575831 - Attachment is obsolete: true
Attachment #575831 - Flags: feedback?(karlt)
Attachment #573836 - Attachment is obsolete: true
MathJax 2.0 is expected to be released before the end of the year, so probably before a fix to this bug is going to be included in a Firefox release. MathJax 2.0 adds support for more stretchy characters so I've included these changes in the set of patches (you have to use http://devel.mathjax.org/testing/mathjax/dpvc/v2.0-candidate/unpacked/MathJax.js in MathJaxFonts.html).

I think I will deal the case of horizontal braces in a separate bug, since it requires to restore the composite char support.
Testing with attachment 579435 [details], it seems that extenders of stretchy arrows are displayed as large black box with the MathJax fonts.
(In reply to Frédéric Wang from comment #8)
> Testing with attachment 579435 [details], it seems that extenders of
> stretchy arrows are displayed as large black box with the MathJax fonts.

OK, there was a typo in MathJaxFonts.html. Now the result is better. However, the following chars do not seem to build correctly:
2961, 21BE, 21A7, 2960, 295C, 21B1, 2951, 295D, 21B0, 27FE, 294F, 21C2, 23B4, 21BF, 21A0, 23B5, 21C3, 21A5
> However, the following chars do not seem to build correctly:
> 2961, 21BE, 21A7, 2960, 295C, 21B1, 2951, 295D, 21B0, 27FE, 294F, 21C2,
> 23B4, 21BF, 21A0, 23B5, 21C3, 21A5

There is a typo in MathJax development version for "21A0", which prevents the character to stretch properly.

The other characters have scale factor on each individual part, so we ca not use them.
Attachment #580098 - Flags: review?(karlt)
Ideally, if we want to render equations like MathJax we should use

MathJax_Math font for mi
MathJax_Main font for other token elements

MathJax_AMS font for mathvariant="double-struck", 
MathJax_Script font for mathvariant="*script"
MathJax_Fraktur font for mathvariant="*fraktur"
MathJax_SansSerif for mathvariant="*serif*"
MathJax_Typewriter for mathvariant="monospace"

However, that seems difficult to do that only in mathml.css, because there are other cases to take into account (fallback the user does not have MathJax fonts, interaction with the fontfamily, style, mathvariant attribute, etc). So I won't do that for the moment.
(In reply to Frédéric Wang from comment #13)
> However, that seems difficult to do that only in mathml.css, because there
> are other cases to take into account (fallback the user does not have
> MathJax fonts, interaction with the fontfamily, style, mathvariant
> attribute, etc). So I won't do that for the moment.

https://tbpl.mozilla.org/?tree=Try&rev=217be55d56ac

The patch I have not attached yet for mathml.css seems to cause the following issue:

layout/reftests/bugs/355548-3.xml
layout/reftests/bugs/355548-4.xml
Attachment #580099 - Flags: review?(karlt) → review+
Comment on attachment 580098 [details] [diff] [review]
Add stretchy operator table for MathJax fonts

Do you think perhaps that STIX fonts should be preferred over MathJax fonts for stretchy characters until mathml.css uses MathJax fonts by default for non-stretchy characters (if that turns out to be workable)?

>+external.6 = MathJax_Main-bold

The PostScript name is MathJax_Main-Bold IIUC, but nsMathMLChar currently deals only with family names, not PostScript names.

This doesn't matter too much because all the @6 entries are commented out, but perhaps it would be worth commenting out external.6 for now and capitalizing "Bold".
Attachment #580098 - Flags: review?(karlt) → review+
Attachment #580098 - Attachment is obsolete: true
OK, I've made the proposed changes.

I'm wondering whether with these patches Web page authors will be able to use MathJax downloadable fonts in MathML formulas. If someone wants to try, the fonts are here:

http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/woff/
Keywords: checkin-needed
Keywords: dev-doc-needed
(In reply to Frédéric Wang from comment #17)
> I'm wondering whether with these patches Web page authors will be able to
> use MathJax downloadable fonts in MathML formulas.

I don't think the changes here, on their own, will improve the situation with downloaded fonts.  I've noted the reason in bug 663740 comment 8.
https://hg.mozilla.org/mozilla-central/rev/1b6a03443c78
https://hg.mozilla.org/mozilla-central/rev/6a39c6d4fbf3
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
I have reorganized the font installation instructions:
https://developer.mozilla.org/en/Mozilla_MathML_Project/Fonts

but we could probably explain better which font files to install and how.
(In reply to Frédéric Wang from comment #21)
> but we could probably explain better which font files to install and how.

I've modified that section (I assume that bug 732834 will be taken for Firefox 13). It remains to update the doc "Firefox 13 for developers" for this bug and bug 732834 (when it is pushed).
(In reply to Frédéric Wang from comment #22)
> It remains to update the doc "Firefox 13 for developers" for
> this bug and bug 732834 (when it is pushed).

Added a note to 
https://developer.mozilla.org/en/Firefox_13_for_developers#MathML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: