-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected replacement of \right) with exlamation point in MathTextParser output #5210
Comments
A bit more investigation - I monkey patched my matplotlib installation - putting in a
This indicates that the bug might originate in a mis-translated character - maybe a missing codepoint in the font? |
For info - I just built off master and replicated this. It's also been replicated on the versions mentioned on SO - mpl 1.4.3 and 1.5.0. I don't think it's relevant, but I've seen it on both Windows and Linux. |
Strangely, it works correctly at |
@QuLogic ha - yes - I hadn't noticed that but you're right certainly on the build I just did from master |
I've done some further digging - sticking some debug prints in
I guess whether it needs the |
OK - I think problem is in this line : https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/mathtext.py#L727 this reads
the |
@rsnape: Your comment that So, yeah, we should check that all those codes are correct. I don't know exactly how to do that, though; I haven found a list of the Bakoma glyphs anywhere. @mdboom? |
In L735 of mathtext.py there is this comment:
It seemed to me that the fourth size was the one giving problems in {} and () as well, so removing them as initially done for [], I got: at all sizes! Maybe we should consider removing the fourth size outright. |
@zblz - my understanding is that 28 and 29 are just the basic paren glyphs and the |
@zblz Yes - maybe a good call to remove them for all, unless it's easy to find exactly which are available and why. The removal solution seems better than falling back on |
Well - I found this which seems to show the lookup, but it does show _EDIT_ Pretty sure this may be relevant - in the ascii table |
To see the glyph table, I usually just open up the fonts in FontForge. You can open the glyph properties for a glyph and it will display the glyph index. |
Looking at the |
In the cmex10 font, As for the fix, I think the thing to do is to add the special names for all of the sized delimiters to Thanks for finding this! It's been lurking there in plain sight for a long time! |
I guess it depends how deeply you want to change this, but I have got a working version by adding to
and in
Tested locally. Happy to turn that into a PR if you like - can get rid of the caveat comment about brackets with that change, too - which I guess adds some commonality. However - I understand if you want to go through doing this for _all_ LaTeX symbol names, or at least checking for potential ASCII clashes. If I'm honest - I'm not exactly sure why I don't see more of the clashes - e.g. I can't get |
Yes, it's probably better if you turn this into a PR and we discuss the implementation there. Thanks! |
Yes -- go ahead and make a PR. I think what you have above is the right idea. I'd like to do this for everything, though, not just the last in each set (just for consistency and to avoid falling into this trap in the future). And, for example, there is an analogous problem with the third size of |
Also, I'm not sure I follow why you think the comment is no longer needed. I don't see 5 different sizes of open square brackets in the Bakoma fonts... It's |
Yes - you're right - I had made a flawed assumption that it was the largest that was believed to be missing (counting the first size as zero) - I didn't notice that the last two in the list were already the |
@mdboom - |
Wow. Good find. Seems like a bug in the font, particularly since there's a missing glyph at I think using the character at Thanks for digging into this rat's nest! |
@rsnape: Are you still planning on submitting a PR for this? |
@mdboom Hi. I was, but I have been given a hard deadline to submit my PhD thesis by end of next week - so won't be able to get to it until late in November. I have a rough PR done, but haven't tested properly. If you can wait, I'll do it late November.. |
Cool, thanks. That's great. |
This appears to be working as of latest |
This is working in 2.0 for me, and there hasn't been any reply for 3 months, so I'm going to close this. |
This bug report originates from my attempts to answer this question on Stack Overflow. Minimal example thanks to the other answer there by Baptiste.
With certain LaTeX strings, the right paranthesis indicates by
\right)
is replaced with an exclamation point when passed to MathTextParser and rendered as a bitmap or png. This behaviour appears to occur when the parantheses are around an expression comprising multiple layered fractions. It does not occur if\right]
or\right\}
are usedThe minimal code to reproduce this is as follows:
This gives output like
Investigations indicate that this occurs only for certain combinations of expression and font size, but the example given above seems to give the most consistent failure conditions. It may be related to
dpi
in the rendering, however this has not yet been conclusively proven or disproven.The text was updated successfully, but these errors were encountered: