Skip to content

Commit c9e4a4f

Browse files
committed
Minor rewrite as per PR21850 comment
1 parent 55881ab commit c9e4a4f

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

‎lib/matplotlib/_mathtext.py‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,39 +2723,35 @@ def subsuper(self, s, loc, toks):
27232723
# node757
27242724
x = Hlist([Kern(subkern), sub])
27252725
x.shrink()
2726-
shift_temp = constants.sub1 * xHeight
27272726
if self.is_dropsub(last_char):
27282727
shift_down = lc_baseline + constants.subdrop * xHeight
2729-
elif (s.startswith(r'\left', loc)
2730-
and nucleus.depth > shift_temp - capHeight / 10):
2731-
shift_down = nucleus.depth + capHeight / 10
27322728
else:
27332729
shift_down = constants.sub1 * xHeight
2730+
if s.startswith(r'\left', loc):
2731+
shift_down = max(
2732+
shift_down, nucleus.depth + capHeight / 10)
27342733
x.shift_amount = shift_down
27352734
else:
27362735
x = Hlist([Kern(superkern), super])
27372736
x.shrink()
2738-
shift_temp = constants.sup1 * xHeight
27392737
if self.is_dropsub(last_char):
27402738
shift_up = lc_height - constants.subdrop * xHeight
2741-
elif (s.startswith(r'\left', loc)
2742-
and nucleus.height > shift_temp + capHeight * 1/3):
2743-
shift_up = nucleus.height - capHeight * 1/3
27442739
else:
27452740
shift_up = constants.sup1 * xHeight
2741+
if s.startswith(r'\left', loc):
2742+
shift_up = max(shift_up, nucleus.height - capHeight / 3)
27462743
if sub is None:
27472744
x.shift_amount = -shift_up
27482745
else: # Both sub and superscript
27492746
y = Hlist([Kern(subkern), sub])
27502747
y.shrink()
2751-
shift_temp = constants.sub2 * xHeight
27522748
if self.is_dropsub(last_char):
27532749
shift_down = lc_baseline + constants.subdrop * xHeight
2754-
elif (s.startswith(r'\left', loc)
2755-
and nucleus.depth > shift_temp - capHeight / 10):
2756-
shift_down = nucleus.depth + capHeight / 10
27572750
else:
27582751
shift_down = constants.sub2 * xHeight
2752+
if s.startswith(r'\left', loc):
2753+
shift_down = max(
2754+
shift_down, nucleus.depth + capHeight / 10)
27592755
# If sub and superscript collide, move super up
27602756
clr = (2.0 * rule_thickness -
27612757
((shift_up - x.depth) - (y.height - shift_down)))

0 commit comments

Comments
 (0)