8000 Fix #5444: do not access subsuper nucleus _metrics if not available by zblz · Pull Request #5448 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix #5444: do not access subsuper nucleus _metrics if not available #5448

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

Merged
merged 3 commits into from
Nov 9, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Only check _metrics of subsuper nucleus if available
Fixes #5444
  • Loading branch information
zblz committed Nov 9, 2015
commit f83daa76942b95ce5c16f1ab358b24e60ac86a08
6 changes: 4 additions & 2 deletions lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2859,10 +2859,12 @@ def subsuper(self, s, loc, toks):
new_children = nucleus.children
if len(new_children):
# remove last kern
if isinstance(new_children[-1],Kern):
if (isinstance(new_children[-1],Kern) and
hasattr(new_children[-2], '_metrics')):
new_children = new_children[:-1]
last_char = new_children[-1]
last_char.width = last_char._metrics.advance
if hasattr(last_char, '_metrics'):
last_char.width = last_char._metrics.advance
# create new Hlist without kerning
nucleus = Hlist(new_children, do_kern=False)
else:
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
r'testing$^{123}$',
' '.join('$\\' + p + '$' for p in sorted(mathtext.Parser._snowflake)),
r'$6-2$; $-2$; $ -2$; ${-2}$; ${ -2}$; $20^{+3}_{-2}$',
r'$\overline{\omega}^x \frac{1}{2}_0^x$', # github issue #5444
]

digits = "0123456789"
Expand Down
0