mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.25k stars 1.16k forks source link

Failure to correctly display Persian text in the formula in the Firefox browser #3142

Open saraOrkide opened 12 months ago

saraOrkide commented 12 months ago

The Persian text in the formula is displayed as letters instead of being stuck together Of course, in the Chrome browser, it is the same in Firefox ex mml Code: `

( a , 1 ) ت ا ب ع   ه م ا ن ی a = 1 ( b , 2 ) ت ا ب ع   ه م ا ن ی b = 2 ( c , 5 ) ت ا ب ع   ه م ا ن ی c = 5

` result: Screenshot from 2023-12-05 17-00-21

matjax version 2.7.1

dpvc commented 12 months ago

Because you have each Persian character in a separate <mi> element, they are not able to interact to form the combined characters that you are expecting. For characters that form words or phrases, you would want to put them all inside a single <mtext> element, as in <mtext>تابع همانی</mtext>. Then you need to configure MathJax to use the surrounding font for mtext elements, rather than its own fonts (which don't include these characters). You don't indicate what output jax you are using, so something like

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  CommonHTML: {
    mtextFontInherit: true
  },
  SVG: {
    mtextFontInherit: true
  },
  "HTML-CSS": {
    mtextFontInherit: true
  }
});
</script>

should do the trick. You also probably want to put an mrow around the parentheses to keep them from growing to the size of the mover element. For example:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mtable columnalign="left">
    <mtr>
      <mtd>
        <mrow>
          <mo>(</mo>
          <mi>a</mi>
          <mo>,</mo>
          <mn>1</mn>
          <mo>)</mo>
        </mrow>
        <mover accent="false">
          <mo>→</mo>
          <mtext>تابع همانی</mtext>
        </mover>
        <mi>a</mi>
        <mo>=</mo>
        <mn>1</mn>
      </mtd>
      <mtd></mtd>
    </mtr>
    <mtr>
      <mtd>
        <mrow>
          <mo>(</mo>
          <mi>b</mi>
          <mo>,</mo>
          <mn>2</mn>
          <mo>)</mo>
        </mrow>
        <mover accent="false">
          <mo>→</mo>
          <mtext>تابع همانی</mtext>
        </mover>
        <mi>b</mi>
        <mo>=</mo>
        <mn>2</mn>
      </mtd>
      <mtd></mtd>
    </mtr>
    <mtr>
      <mtd>
        <mrow>
          <mo>(</mo>
          <mi>c</mi>
          <mo>,</mo>
          <mn>5</mn>
          <mo>)</mo>
        </mrow>
        <mover accent="false">
          <mo>→</mo>
          <mtext>تابع همانی</mtext>
        </mover>
        <mi>c</mi>
        <mo>=</mo>
        <mn>5</mn>
      </mtd>
      <mtd></mtd>
    </mtr>
    <mtr>
      <mtd></mtd>
      <mtd></mtd>
    </mtr>
  </mtable>
</math>

would produce

Persian

in the HTML-CSS output jax.

dpvc commented 12 months ago

Duplicate of #2426

dpvc commented 12 months ago

PS, you really should update your version of MathJax. v2.7.1 is quite old. The current version is 3.2.2, with v4.0 out in beta release. The current v2 version is 2.7.9.

saraOrkide commented 12 months ago
<mtext>تابع همانی</mtext>

Thank you