Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a32194

Browse files
committed
first attempt
finetuning with cm TeX match superscript height
1 parent d22f626 commit 3a32194

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

lib/matplotlib/mathtext.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,15 +1187,16 @@ def get_underline_thickness(self, font, fontsize, dpi):
11871187
# get any smaller
11881188
NUM_SIZE_LEVELS = 6
11891189
# Percentage of x-height of additional horiz. space after sub/superscripts
1190-
SCRIPT_SPACE = 0.2
1190+
SCRIPT_SPACE = -0.10
11911191
# Percentage of x-height that sub/superscripts drop below the baseline
11921192
SUBDROP = 0.3
11931193
# Percentage of x-height that superscripts drop below the baseline
1194-
SUP1 = 0.5
1194+
SUP1 = 0.4
11951195
# Percentage of x-height that subscripts drop below the baseline
11961196
SUB1 = 0.0
1197-
# Percentage of x-height that superscripts are offset relative to the subscript
1198-
DELTA = 0.18
1197+
# Percentage of x-height that supercripts are offset relative to the subscript
1198+
# for slanted nuclei
1199+
DELTA = 0.15
11991200

12001201
class MathTextWarning(Warning):
12011202
pass
@@ -2736,33 +2737,30 @@ def subsuper(self, s, loc, toks):
27362737
# node757
27372738
sub.shrink()
27382739
x = Hlist([sub])
2739-
# x.width += SCRIPT_SPACE * xHeight
2740+
x.width += SCRIPT_SPACE * xHeight
27402741
shift_down = max(shift_down, SUB1)
27412742
clr = x.height - (abs(xHeight * 4.0) / 5.0)
27422743
shift_down = max(shift_down, clr)
2743-
x.shift_amount = shift_down
2744+
x.shift_amount = shift_down / 2.
27442745
else:
27452746
super.shrink()
27462747
x = Hlist([super])
2747-
# x.width += SCRIPT_SPACE * xHeight
2748-
clr = SUP1 * xHeight
2749-
shift_up = max(shift_up, clr)
2750-
clr = x.depth + (abs(xHeight) / 4.0)
2751-
shift_up = max(shift_up, clr)
2748+
x.width += SCRIPT_SPACE * xHeight
2749+
shift_up = SUP1 * xHeight
2750+
if self.is_slanted(nucleus):
2751+
x = Hlist([Kern(DELTA * x.height),x])
27522752
if sub is None:
27532753
x.shift_amount = -shift_up
27542754
else: # Both sub and superscript
27552755
sub.shrink()
27562756
y = Hlist([sub])
2757-
# y.width += SCRIPT_SPACE * xHeight
2757+
y.width += SCRIPT_SPACE * xHeight
27582758
shift_down = max(shift_down, SUB1 * xHeight)
2759+
# If sub and superscript collide, move sup up
27592760
clr = (2.0 * rule_thickness -
27602761
((shift_up - x.depth) - (y.height - shift_down)))
27612762
if clr > 0.:
27622763
shift_up += clr
2763-
shift_down += clr
2764-
if self.is_slanted(nucleus):
2765-
x.shift_amount = DELTA * (shift_up + shift_down)
27662764
x = Vlist([x,
27672765
Kern((shift_up - x.depth) - (y.height - shift_down)),
27682766
y])

0 commit comments

Comments
 (0)