Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix glyphs for angle brackets#26518
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
QuLogic commentedAug 19, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'm not sure about the spacing of the result. The rightmost side of the left angle appears to be half as close as the leftmost side of the right angle. For the first three examples, it's about 1 vs 2 pixels, while about 2 vs 4 on the rightmost largest one. If you take your test and call it withonly @image_comparison(baseline_images=['math_angle_brackets.png']*2)deftest_math_angle_brackets():tests= [r'$\left< x \right>$',r'$\left< ? \right>$',r'$\left< \frac{1}{2}\right>$',r'$\left< \frac{\sum_{0}^{1}}{2}\right>$',r'$\left<\frac{\sum_{0}^{1}}{\sum_{0}^{1}}\right>$' ]forleft,rightin [('<','>'), (r'\langle',r'\rangle')]:fig=plt.figure(figsize=(5,1))foridx,textinenumerate(tests):fig.text((idx+0.3)/len(tests),0.5,text.replace('<',left).replace('>',right),math_fontfamily='cm') |
I reverted the changes and tested the code again. The misalignment appears due to the missing sizing of the angle brackets, but reordering the sizing for the glyphs following this diff, generates the following image, which seems to be centered(?) with --- a/lib/matplotlib/_mathtext.py+++ b/lib/matplotlib/_mathtext.py@@ -419,10 +419,10 @@ class BakomaFonts(TruetypeFonts): ('ex', '\xbb'), ('ex', '\x26')], r'\rceil': [('ex', '\xa8'), ('ex', '\x6d'), ('ex', '\xbc'), ('ex', '\x27')],- r'\langle': [('ex', '\xad'), ('ex', '\x44'),- ('ex', '\xbf')],- r'\rangle': [('ex', '\xae'), ('ex', '\x45'),- ('ex', '\xc0')],+ r'\langle': [('ex', '\xad'), ('ex', '\x2a'),+ ('ex', '\xbf'), ('ex', '\x44')],+ r'\rangle': [('ex', '\xae'), ('ex', '\x2b'),+ ('ex', '\xc0'), ('ex', '\x45')], r'\__sqrt__': [('ex', '\x70'), ('ex', '\x71'), ('ex', '\x72'), ('ex', '\x73')], r'\backslash': [('ex', '\xb2'), ('ex', '\x2f'),@@ -433,6 +433,8 @@ class BakomaFonts(TruetypeFonts): ('ex', '\x64')], r'\widetilde': [('rm', '\x7e'), ('ex', '\x65'), ('ex', '\x66'), ('ex', '\x67')],+ r'<': [('ex', '\x44')],+ r'>': [('ex', '\x45')] } |
Sorry it's taken a while to get back to this PR. I don't believe it is the correct approach as the glyph orderis correct at the moment. The problem is really that the character code gets mapped twice. I've opened#29936 to correct this, which should replace this PR. |
PR summary
Fixes#18740
PR checklist