mathjax / MathJax-node

MathJax for Node
Apache License 2.0
615 stars 97 forks source link

mathML unicode character 23DC not rendered correctly in SVG #202

Closed corinnaSchultz closed 8 years ago

corinnaSchultz commented 8 years ago

This is the "top parenthesis" character. When it is place over a single letter, it isn't rendered correctly. It appears to be made out of two halves, and they overlap in the middle.

 <math xmlns="http://www.w3.org/2010/Math/MathML"><semantics><mstyle scriptsizemultiplier="0.715"><mover><mi>x</mi><mo>&#x23DC;</mo></mover></mstyle><annotation encoding="text/plain"/></semantics></math>
topparen
 <svg xmlns:xlink="http://www.w3.org/1999/xlink" style="vertical-align: -0.338ex; margin-right: -0.056ex;" width="1.422ex" height="2.676ex" viewBox="0 -1006.6 612.3 1152.1" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg">\n<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">\n<path stroke-width="1" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"></path>\n<g transform="translate(39,764)">\n<path stroke-width="1" d="M-18 -213L-24 -207V-172L-16 -158Q75 2 260 84Q334 113 415 119Q418 119 427 119T440 120Q454 120 457 117T460 98V60V25Q460 7 457 4T441 0Q308 0 193 -55T25 -205Q21 -211 18 -212T-1 -213H-18Z" transform="translate(23,0)"></path>\n<path stroke-width="1" d="M-10 60Q-10 104 -10 111T-5 118Q-1 120 10 120Q96 120 190 84Q375 2 466 -158L474 -172V-207L468 -213H451H447Q437 -213 434 -213T428 -209T423 -202T414 -187T396 -163Q331 -82 224 -41T9 0Q-4 0 -7 3T-10 25V60Z" transform="translate(98,0)"></path>\n</g>\n</g>\n</svg>

When this character is used over more than one letter, as in the following example, it renders correctly, as it's constructed from three pieces

 <math xmlns="http://www.w3.org/2010/Math/MathML"><semantics><mstyle scriptsizemultiplier="0.715"><mover><mrow><mi>x</mi><mi>z</mi></mrow><mo>&#x23DC;</mo></mover></mstyle><annotation encoding="text/plain"/></semantics></math>

output:

 <svg xmlns:xlink="http://www.w3.org/1999/xlink" style="vertical-align: -0.338ex; margin-right: -0.032ex;" width="2.45ex" height="2.676ex" viewBox="0 -1006.6 1055 1152.1" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg">\n<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">\n<path stroke-width="1" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"></path>\n<g transform="translate(572,0)">\n<path stroke-width="1" d="M347 338Q337 338 294 349T231 360Q211 360 197 356T174 346T162 335T155 324L153 320Q150 317 138 317Q117 317 117 325Q117 330 120 339Q133 378 163 406T229 440Q241 442 246 442Q271 442 291 425T329 392T367 375Q389 375 411 408T434 441Q435 442 449 442H462Q468 436 468 434Q468 430 463 420T449 399T432 377T418 358L411 349Q368 298 275 214T160 106L148 94L163 93Q185 93 227 82T290 71Q328 71 360 90T402 140Q406 149 409 151T424 153Q443 153 443 143Q443 138 442 134Q425 72 376 31T278 -11Q252 -11 232 6T193 40T155 57Q111 57 76 -3Q70 -11 59 -11H54H41Q35 -5 35 -2Q35 13 93 84Q132 129 225 214T340 322Q352 338 347 338Z"></path>\n</g>\n<g transform="translate(13,764)">\n<path stroke-width="1" d="M-18 -213L-24 -207V-172L-16 -158Q75 2 260 84Q334 113 415 119Q418 119 427 119T440 120Q454 120 457 117T460 98V60V25Q460 7 457 4T441 0Q308 0 193 -55T25 -205Q21 -211 18 -212T-1 -213H-18Z" transform="translate(23,0)"></path>\n<g transform="translate(485.6511904761905,0) scale(0.1738095238095238,1)">\n<path stroke-width="1" d="M-10 0V120H410V0H-10Z"></path>\n</g>\n<path stroke-width="1" d="M-10 60Q-10 104 -10 111T-5 118Q-1 120 10 120Q96 120 190 84Q375 2 466 -158L474 -172V-207L468 -213H451H447Q437 -213 434 -213T428 -209T423 -202T414 -187T396 -163Q331 -82 224 -41T9 0Q-4 0 -7 3T-10 25V60Z" transform="translate(566,0)"></path>\n</g>\n</g>\n</svg>
corinnaSchultz commented 8 years ago

There may be something similar going on with these characters:

x21C0

 <math xmlns="http://www.w3.org/2010/Math/MathML"><semantics><mstyle scriptsizemultiplier="0.715"><mover><mi>x</mi><mo>&#x21C0;</mo></mover></mstyle><annotation encoding="text/plain"/></semantics></math>

x023DD

 <math xmlns="http://www.w3.org/2010/Math/MathML"><semantics><mstyle scriptsizemultiplier="0.715"><munder><mi>x</mi><mo>&#x023DD;</mo></munder></mstyle><annotation encoding="text/plain"></annotation></semantics></math>
dpvc commented 8 years ago

It turns out that the data for certain of the stretchy characters is off (the widths of the single-character versions were supposed to be multiplied by 1000, but are decimals instead, so the widths are not being processed correctly, and the single-character versions are not being selected when they should).

For the time being, you can either use the STIX fonts, which have the correct data, or use stretchy="false" on the <mo>. You might also find accent="false" to improve some of them.

corinnaSchultz commented 8 years ago

Another symbol which may be in this category too (I'm not sure if the underbar is supposed to be that wide):

 <math xmlns="http://www.w3.org/2010/Math/MathML"><semantics><mstyle scriptsizemultiplier="0.715"><menclose notation="bottom"><mi>x</mi></menclose></mstyle><annotation encoding="text/plain"></annotation></semantics></math>

 <svg xmlns:xlink="http://www.w3.org/1999/xlink" style="vertical-align: -0.838ex;" width="2.607ex" height="2.176ex" viewBox="0 -576.1 1122.5 936.9" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg">\n<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">\n<g transform="translate(275,0)">\n<path stroke-width="1" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"></path>\n</g>\n<line stroke-linecap="square" stroke="black" stroke-width="75" y2="37" y1="37" x1="37" x2="1085" transform="translate(0,-287)"></line>\n</g>\n</svg>
dpvc commented 8 years ago

Your latest example uses <menclose>, and although the MathML spec is not specific about the expected renderings, it does suggest a small amount of padding for several of the notations. Most renderers use this padding for all the box-like notations; MathJax does this as well. So, yes, the extra width is the expected result.

If you are looking for a tighter underline, try

<math xmlns="http://www.w3.org/2010/Math/MathML">
  <munder>
    <mi>x</mi>
    <mo>_</mo>
  </munder>
</math>
pkra commented 8 years ago

Now that MathJax has hit 2.7-beta (and includes the fix), I think we can close this.

brando90 commented 6 years ago

how does one write underbar?

dpvc commented 6 years ago

@brando90, as indicated above,

<math xmlns="http://www.w3.org/2010/Math/MathML">
  <munder>
    <mi>x</mi>
    <mo>_</mo>
  </munder>
</math>

will put an underbar under an "x".

On the other hand, if you mean you want to show x_1 with an actual underbar in it, then you can use something like

<math xmlns="http://www.w3.org/2010/Math/MathML">
  <mi>x_1</mi>
</math>

If neither of these is what you are after, then you need to be clearer about what you are trying to accomplish.