Last Comment Bug 701758 - (mathjax-fonts) Support for MathJax fonts
(mathjax-fonts)
: Support for MathJax fonts
Status: RESOLVED FIXED
: dev-doc-complete
Product: Core
Classification: Components
Component: MathML (show other bugs)
: Trunk
: All All
: -- normal with 1 vote (vote)
: mozilla13
Assigned To: Frédéric Wang (:fredw)
:
:
Mentors:
http://groups.google.com/group/mathja...
Depends on:
Blocks: mathml-in-mathjax
  Show dependency treegraph
 
Reported: 2011-11-11 09:46 PST by Frédéric Wang (:fredw)
Modified: 2012-03-24 06:34 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Experimental patch (2.33 KB, patch)
2011-11-11 09:46 PST, Frédéric Wang (:fredw)
no flags Details | Diff | Splinter Review
Screnshot of MathML torture test with patch applied (20.57 KB, image/png)
2011-11-11 09:49 PST, Frédéric Wang (:fredw)
no flags Details
Patch - part 2 (13.12 KB, patch)
2011-11-21 04:32 PST, Frédéric Wang (:fredw)
no flags Details | Diff | Splinter Review
Screnshot of MathML torture test with patches applied (16.10 KB, image/png)
2011-11-23 02:42 PST, Frédéric Wang (:fredw)
no flags Details
Add stretchy operator table for MathJax fonts (15.24 KB, patch)
2011-12-08 10:41 PST, Frédéric Wang (:fredw)
karlt: review+
Details | Diff | Splinter Review
Add page to convert MathJax font table into our own format (7.63 KB, patch)
2011-12-08 10:41 PST, Frédéric Wang (:fredw)
karlt: review+
Details | Diff | Splinter Review
Add stretchy operator table for MathJax fonts (V2) (15.24 KB, patch)
2012-02-27 22:35 PST, Frédéric Wang (:fredw)
no flags Details | Diff | Splinter Review

Description Frédéric Wang (:fredw) 2011-11-11 09:46:56 PST
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.
Comment 1 Frédéric Wang (:fredw) 2011-11-11 09:49:58 PST
Created attachment 573838 [details]
Screnshot of MathML torture test with patch applied
Comment 2 Frédéric Wang (:fredw) 2011-11-19 04:08:59 PST
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.
Comment 3 Frédéric Wang (:fredw) 2011-11-21 04:32:07 PST
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.
Comment 4 Frédéric Wang (:fredw) 2011-11-21 04:41:25 PST
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?
Comment 5 Karl Tomlinson (:karlt) 2011-11-22 19:23:59 PST
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.
Comment 6 Frédéric Wang (:fredw) 2011-11-23 02:42:14 PST
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.
Comment 7 Frédéric Wang (:fredw) 2011-11-23 15:00:03 PST
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.
Comment 8 Frédéric Wang (:fredw) 2011-12-06 13:32:24 PST
Testing with attachment 579435 [details], it seems that extenders of stretchy arrows are displayed as large black box with the MathJax fonts.
Comment 9 Frédéric Wang (:fredw) 2011-12-07 11:02:14 PST
(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
Comment 10 Frédéric Wang (:fredw) 2011-12-07 11:32:27 PST
> 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.
Comment 11 Frédéric Wang (:fredw) 2011-12-08 10:41:27 PST
Created attachment 580098 [details] [diff] [review]
Add stretchy operator table for MathJax fonts
Comment 12 Frédéric Wang (:fredw) 2011-12-08 10:41:59 PST
Created attachment 580099 [details] [diff] [review]
Add page to convert MathJax font table into our own format
Comment 13 Frédéric Wang (:fredw) 2011-12-08 10:47:55 PST
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.
Comment 14 Frédéric Wang (:fredw) 2011-12-08 10:51:03 PST
(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
Comment 15 Karl Tomlinson (:karlt) 2012-02-27 19:30:20 PST
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".
Comment 16 Frédéric Wang (:fredw) 2012-02-27 22:35:22 PST
Created attachment 601183 [details] [diff] [review]
Add stretchy operator table for MathJax fonts (V2)
Comment 17 Frédéric Wang (:fredw) 2012-02-27 22:41:11 PST
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/
Comment 18 Karl Tomlinson (:karlt) 2012-02-28 14:24:19 PST
(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.
Comment 21 Frédéric Wang (:fredw) 2012-03-09 01:44:32 PST
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.
Comment 22 Frédéric Wang (:fredw) 2012-03-09 04:44:06 PST
(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).
Comment 23 Florian Scholz [:fscholz] (MDN) 2012-03-24 06:34:15 PDT
(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

Note You need to log in before you can comment on or make changes to this bug.