@@ -1187,16 +1187,31 @@ def get_underline_thickness(self, font, fontsize, dpi):
1187
1187
# get any smaller
1188
1188
NUM_SIZE_LEVELS = 6
1189
1189
# Percentage of x-height of additional horiz. space after sub/superscripts
1190
- SCRIPT_SPACE = 0.00
1191
- # Percentage of x-height that sub/superscripts drop below the baseline
1192
- SUBDROP = 0.3
1190
+ SCRIPT_SPACE = {'cm' : 0.03 ,
1191
+ 'stix' : 0.10 ,
1192
+ 'stixsans' : 0.10 }
1193
+ ## Percentage of x-height that sub/superscripts drop below the baseline
1194
+ SUBDROP = {'cm' : 0.3 ,
1195
+ 'stix' : 0.3 ,
1196
+ 'stixsans' : 0.3 }
1193
1197
# Percentage of x-height that superscripts drop below the baseline
1194
- SUP1 = 0.4
1198
+ SUP1 = {'cm' : 0.4 ,
1199
+ 'stix' : 0.8 ,
1200
+ 'stixsans' : 0.8 }
1195
1201
# Percentage of x-height that subscripts drop below the baseline
1196
- SUB1 = 0.0
1202
+ SUB1 = {'cm' : 0.4 ,
1203
+ 'stix' : 0.6 ,
1204
+ 'stixsans' : 0.6 }
1205
+ # Percentage of x-height that subscripts drop below the baseline when a
1206
+ # superscript is present
1207
+ SUB2 = {'cm' : 0.3 ,
1208
+ 'stix' : 0.6 ,
1209
+ 'stixsans' : 0.5 }
1197
1210
# Percentage of x-height that supercripts are offset relative to the subscript
1198
1211
# for slanted nuclei
1199
- DELTA = 0.10
1212
+ DELTA = {'cm' : 0.10 ,
1213
+ 'stix' : 0.15 ,
1214
+ 'stixsans' : 0.25 }
1200
1215
1201
1216
class MathTextWarning (Warning ):
1202
1217
pass
@@ -2693,6 +2708,11 @@ def subsuper(self, s, loc, toks):
2693
2708
xHeight = state .font_output .get_xheight (
2694
2709
state .font , state .fontsize , state .dpi )
2695
2710
2711
+ fs = rcParams ['mathtext.fontset' ]
2712
+ # If a custom fontset is used, use CM parameters
2713
+ if fs == 'custom' :
2714
+ fs = 'cm'
2715
+
2696
2716
if napostrophes :
2697
2717
if super is None :
2698
2718
super = Hlist ([])
@@ -2729,35 +2749,35 @@ def subsuper(self, s, loc, toks):
2729
2749
return [result ]
2730
2750
2731
2751
# Handle regular sub/superscripts
2732
- shift_up = nucleus .height - SUBDROP * xHeight
2752
+ shift_up = nucleus .height - SUBDROP [ fs ] * xHeight
2733
2753
if self .is_dropsub (nucleus ):
2734
- shift_down = nucleus .depth + SUBDROP * xHeight
2754
+ shift_down = nucleus .depth + SUBDROP [ fs ] * xHeight
2735
2755
else :
2736
- shift_down = SUBDROP * xHeight
2756
+ shift_down = SUBDROP [ fs ] * xHeight
2737
2757
if super is None :
2738
2758
# node757
2739
2759
x = Hlist ([sub ])
2740
2760
x .shrink ()
2741
- x .width += SCRIPT_SPACE * xHeight
2742
- shift_down = max (shift_down , SUB1 )
2743
- clr = x .height - (abs (xHeight * 4.0 ) / 5.0 )
2744
- shift_down = max (shift_down , clr )
2761
+ x .width += SCRIPT_SPACE [ fs ] * xHeight
2762
+ shift_down = max (shift_down , SUB1 [ fs ] * xHeight )
2763
+ # clr = x.height - (abs(xHeight * 4.0) / 5.0)
2764
+ # shift_down = max(shift_down, clr)
2745
2765
x .shift_amount = shift_down / 2.
2746
2766
else :
2747
2767
if self .is_slanted (last_char ):
2748
- x = Hlist ([Kern (DELTA * super .height ),super ])
2768
+ x = Hlist ([Kern (DELTA [ fs ] * super .height ),super ])
2749
2769
else :
2750
2770
x = Hlist ([super ])
2751
2771
x .shrink ()
2752
- x .width += SCRIPT_SPACE * xHeight
2753
- shift_up = SUP1 * xHeight
2772
+ x .width += SCRIPT_SPACE [ fs ] * xHeight
2773
+ shift_up = SUP1 [ fs ] * xHeight
2754
2774
if sub is None :
2755
2775
x .shift_amount = - shift_up
2756
2776
else : # Both sub and superscript
2757
2777
y = Hlist ([sub ])
2758
2778
y .shrink ()
2759
- y .width += SCRIPT_SPACE * xHeight
2760
- shift_down = max (shift_down , SUB1 * xHeight )
2779
+ y .width += SCRIPT_SPACE [ fs ] * xHeight
2780
+ shift_down = max (shift_down , SUB2 [ fs ] * xHeight )
2761
2781
# If sub and superscript collide, move sup up
2762
2782
clr = (2.0 * rule_thickness -
2763
2783
((shift_up - x .depth ) - (y .height - shift_down )))
0 commit comments