Note: There are a few cases of duplicates in user autocompletion which are being worked on.
Bug 701758 (mathjax-fonts)

Support for MathJax fonts

RESOLVED FIXED in mozilla13

Status

()

Core
MathML
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: fredw, Assigned: fredw)

Tracking

(Blocks: 1 bug, {dev-doc-complete})

Trunk
mozilla13
dev-doc-complete
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(3 attachments, 4 obsolete attachments)

(Assignee)

Description

6 years ago
Created attachment 573836 [details] [diff] [review]
Experimental patch

(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.
(Assignee)

Comment 1

6 years ago
Created attachment 573838 [details]
Screnshot of MathML torture test with patch applied
(Assignee)

Comment 2

6 years ago
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.
(Assignee)

Comment 3

6 years ago
Created attachment 575831 [details] [diff] [review]
Patch - part 2

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)
(Assignee)

Comment 4

6 years ago
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.
(Assignee)

Comment 6

6 years ago
Created attachment 576433 [details]
Screnshot of MathML torture test with patches applied

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
(Assignee)

Updated

6 years ago
Attachment #576433 - Attachment is patch: false
Attachment #576433 - Attachment mime type: text/plain → image/png
(Assignee)

Updated

6 years ago
Attachment #575831 - Attachment is obsolete: true
Attachment #575831 - Flags: feedback?(karlt)
(Assignee)

Updated

6 years ago
Attachment #573836 - Attachment is obsolete: true
(Assignee)

Comment 7

6 years ago
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.
(Assignee)

Comment 8

6 years ago
Testing with attachment 579435 [details], it seems that extenders of stretchy arrows are displayed as large black box with the MathJax fonts.
(Assignee)

Comment 9

6 years ago
(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
(Assignee)

Comment 10

6 years ago
> 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.
(Assignee)

Comment 11

6 years ago
Created attachment 580098 [details] [diff] [review]
Add stretchy operator table for MathJax fonts
Attachment #580098 - Flags: review?(karlt)
(Assignee)

Comment 12

6 years ago
Created attachment 580099 [details] [diff] [review]
Add page to convert MathJax font table into our own format
Attachment #580099 - Flags: review?(karlt)
(Assignee)

Comment 13

6 years ago
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.
(Assignee)

Comment 14

6 years ago
(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+
(Assignee)

Comment 16

6 years ago
Created attachment 601183 [details] [diff] [review]
Add stretchy operator table for MathJax fonts (V2)
Attachment #580098 - Attachment is obsolete: true
(Assignee)

Comment 17

6 years ago
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/
(Assignee)

Updated

6 years ago
Keywords: checkin-needed
(Assignee)

Updated

6 years ago
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/integration/mozilla-inbound/rev/1b6a03443c78
https://hg.mozilla.org/integration/mozilla-inbound/rev/6a39c6d4fbf3
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/1b6a03443c78
https://hg.mozilla.org/mozilla-central/rev/6a39c6d4fbf3
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
(Assignee)

Comment 21

5 years ago
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.
(Assignee)

Comment 22

5 years ago
(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
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.