pressbooks / pb-mathjax

A replacement for wp.com/latex.php but instead of LaTeX, it uses MathJax.
GNU General Public License v3.0
4 stars 1 forks source link

Support Different Fonts #11

Closed dac514 closed 5 years ago

dac514 commented 5 years ago

Add &font=X param to URL. Let the user change the font to use for rendering the mathematics. The default is: font: "TeX"

The possible values are TeX, STIX-Web, Asana-Math, Neo-Euler, Gyre-Pagella, Gyre-Termes and Latin-Modern. Note that not all mathematical characters are available in all fonts (e.g., Neo-Euler does not include italic characters), so some mathematics may work better in some fonts than in others. The STIX-Web font is the most complete.

Source: http://docs.mathjax.org/en/latest/options/output-processors/SVG.html#configure-svg

mcgratay commented 5 years ago

STIX-Web font has trouble rendering LaTeX in PDF format and winds up turning a lot of characters into question marks. Screen Shot 2019-06-28 at 3 22 43 PM StixLaTeXOnly.pdf

https://testbook2948593.textopress.com/

dac514 commented 5 years ago

I posted a question in the PrinceXML forums about the STIX-Web font troubles. Hopefully someone from over there can help explain this.

https://www.princexml.com/forum/topic/4183/mathjax-svg-files-as-img-tags-can-anyone-help-me-with-css

dac514 commented 5 years ago

I've been running tests and this may be the issue:

https://github.com/mathjax/MathJax/issues/2035

Ie.

SVG - Unknown character: U+1D461 in STIXMathJax_Main-bold-italic,STIXMathJax_Normal-bold-italic,STIXMathJax_Script-bold-italic,STIXMathJax_DoubleStruck-bold-italic,STIXMathJax_SansSerif-bold-italic,STIXMathJax_Latin-bold-italic,STIXMathJax_Alphabets-bold-italic,STIXMathJax_Marks-bold-italic,STIXMathJax_Shapes-bold-italic,STIXMathJax_Misc-bold-italic,STIXMathJax_Variants-bold-italic,STIXMathJax_Size1

pkra commented 5 years ago

I've been running tests and this may be the issue:

Just FYI "unknown character" means that MathJax did not find a path matching the unicode point (i.e., didn't find a glyph in the original font); in those cases it falls back to an SVG text element with Unicode in it (which is not ideal since fons won't match); this may very well be a problem for Prince but it's fairly normal for SVGs to have <text> elements.

dac514 commented 5 years ago

it's fairly normal for SVGs to have \<text> elements

Thanks @pkra. The SVG's with text nodes render fine in the browser:

image

As I type, the problem can be split into 3 distinct issues:

  1. I expect Prince to behave like a browser. Prince should render text nodes in SVG files like how a browser does. Hopefully the forum thread leads to a solution.
  2. Can't find U+1D461 in Stix-Web. This gets fixed if I apply either of the patches from https://github.com/mathjax/MathJax/issues/2035
  3. Pb-mathjax, using mathjax-node, generates a PNG from the SVG using Sharp. When a font can't be found in #2, it affects this process:

image

(and goes away with either https://github.com/mathjax/MathJax/issues/2035 patch:)

image

dac514 commented 5 years ago

PS: Here's the text case:

\boldsymbol{\Delta{p}_1=F_1\Delta{t},}