Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
devRD wants to merge2 commits intomatplotlib:mainfromdevRD:mt-angled
Closed

Conversation

devRD
Copy link
Contributor

PR summary

Fixes#18740

Figure_1_cal

PR checklist

@devRDdevRD marked this pull request as ready for reviewAugust 15, 2023 11:12
@QuLogic
Copy link
Member

QuLogic commentedAug 19, 2023
edited
Loading

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<> or only\langle\rangle and revert the other changes, then the text between<> all appear centred (though of course the other version is broken as in#18740.) Something like:

@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')

@devRD
Copy link
ContributorAuthor

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(?) withcm but a bit wonky withcustom fonts

--- 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')]         }

Image for CM font:
math_angle_brackets

Image for Custom font:
math_angle_brackets

@QuLogic
Copy link
Member

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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ksundenksundenksunden approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Incorrect glyphs selected for angle brackets
3 participants
@devRD@QuLogic@ksunden

[8]ページ先頭

©2009-2025 Movatter.jp