Ugly, mis-aligned MathML unless use_document_fonts is disabled

UNCONFIRMED
Unassigned

Status

()

UNCONFIRMED
3 years ago
2 years ago

People

(Reporter: benjaminmoody, Unassigned)

Tracking

38 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(5 attachments)

(Reporter)

Description

3 years ago
Created attachment 8730471 [details]
example of ugly rendering

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0
Build ID: 20160308235518

Steps to reproduce:

Using Firefox 38.7.0 on Scientific Linux 6:

View a document containing MathML, such as the examples here: https://developer.mozilla.org/en-US/docs/Web/MathML/Examples

Turn off site stylesheets (View > Page Style > No Style) to eliminate any confounding factors.

Compare the appearance of the equations when browser.display.use_document_fonts is set to 1 (the default), versus when it is set to 0.


Actual results:

When browser.display.use_document_fonts is enabled, equations are formatted poorly.  It looks as though the vertical *center* of an MO element is somehow being aligned with the *baseline* of an MI or MN element.  There also seems to be insufficient space between the children of an MFRAC.

When browser.display.use_document_fonts is disabled, equations look reasonable.

This is true regardless of whether the document uses custom fonts, or indeed, any stylesheets at all.


Expected results:

In the absence of custom stylesheets, equations should be aligned properly.

Updated

3 years ago
Component: Untriaged → MathML
Product: Firefox → Core
I'm not sure I can explain/reproduce your problem, but did you try following the instructions on

https://developer.mozilla.org/en-US/docs/Mozilla/MathML_Project/Fonts ?

(I wish "Scientific" Linux install math fonts by default...)
(Reporter)

Comment 2

3 years ago
Thanks for the tip.  Here's some more information.

- I had the stix-fonts package installed (I don't remember if this was
  installed by default or if I installed it at some point in the past.
  It's not a dependency of the firefox package.)  This package
  includes the "STIXGeneral" fonts:
    STIXGeneral.otf
    STIXGeneralBol.otf
    STIXGeneralBolIta.otf
    STIXGeneralItalic.otf

- I also had some fonts in ~/.fonts/, which I must have placed there
  myself, though I don't remember when or why.  These include "STIX"
  and "STIX Math":
    STIX-Bold.otf
    STIX-BoldItalic.otf
    STIX-Italic.otf
    STIX-Regular.otf
    STIXMath-Regular.otf

- If I remove ~/.fonts, but leave the stix-fonts package in place,
  equations are still rendered badly.

- If I remove the stix-fonts package, but leave ~/.fonts in place,
  equations are rendered properly (apparently using "STIX Math".)

- If I also remove "STIX Math" (leaving only "STIX"), equations are
  readable but not great (see the radical sign.)

- If I remove all of these fonts, equations are rendered properly
  (using DejaVu Serif, I think); in this case, it looks roughly the
  same regardless of use_document_fonts.

Conclusions:

- Either the STIXGeneral font itself is buggy, or Firefox's handling
  of it.  Firefox should either correct its behavior, or should not
  use STIXGeneral at all.  (Obviously the former would be better since
  STIXGeneral seems to be the only math font available in SL6.)

- Firefox should continue to prefer STIX Math over STIX (and maybe
  should prefer even DejaVu over STIX) and should probably prefer STIX
  Math over STIXGeneral.
(Reporter)

Comment 3

3 years ago
Created attachment 8730929 [details]
rendering using "STIX" font
(Reporter)

Comment 4

3 years ago
Created attachment 8730931 [details]
rendering using "STIX Math" font
Your two screenshots look bad two me (although STIX Math is slightly better for some operators).

What is the value of your font.mathfont-family preference? Do you have any other math addon installed?
Also, note that your version of Firefox is quite old. The latest ESR is Firefox 45 and it includes better math font config: https://developer.mozilla.org/en-US/Firefox/Releases/41#MathML
(Reporter)

Comment 7

3 years ago
These screenshots were all created using a fresh profile.  The value of font.mathfont-family is

Latin Modern Math, XITS Math, STIX Math, Cambria Math, Asana Math, TeX Gyre Bonum Math, TeX Gyre Pagella Math, TeX Gyre Termes Math, Neo Euler, Lucida Bright Math, MathJax_Main, STIXNonUnicode, STIXSizeOneSym, STIXGeneral, Standard Symbols L, DejaVu Sans

which is pretty odd given the behavior I've seen.
Can you try this test (which uses Web fonts) and tell if that looks better:

http://fred-wang.github.io/MathFonts/
(Reporter)

Comment 9

3 years ago
All of the web fonts there load correctly and look acceptable (I wouldn't say any of them look great).  Most have poor hinting, poor spacing for some of the symbols, or both.  TeX Gyre Bonum is probably the best of the bunch but it's a bit plain for my taste.

When the STIXGeneral font is installed, the option "Default fonts (local only)" shows the alignment problems that I saw originally.  The options "Cambria (local only)", "Lucida Bright (local only)", and "Minion (local only)", however, give the same effect as turning off "use_document_fonts" (i.e., the system default font is used.)  Disabling the page stylesheet gives the same effect as "Default fonts (local only)".

Comment 10

2 years ago
I had a similar problem with the ESR version. When I installed a local copy of the latest Firefox (45.1) I had the same problem. However, after adding latinmodern-math.otf to my .fonts directory and running fc-cache resolved the issue with the latest FF version. The problem with the ESR version however remains.

Comment 11

2 years ago
Created attachment 8733372 [details]
After installing latin modern fonts on FF45.1

Comment 12

2 years ago
Created attachment 8733373 [details]
After installing latin modern fonts on FF-ESR38
(Reporter)

Comment 13

2 years ago
SL6 recently updated to Firefox 45.1.0.  The problem is now worse: STIXGeneral is now used (and used brokenly) *regardless* of the value of browser.display.use_document_fonts.
You need to log in before you can comment on or make changes to this bug.