@@ -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
@@ -2696,6 +2711,11 @@ def subsuper(self, s, loc, toks):
2696
2711
xHeight = state .font_output .get_xheight (
2697
2712
state .font , state .fontsize , state .dpi )
2698
2713
2714
+ fs = rcParams ['mathtext.fontset' ]
2715
+ # If a custom fontset is used, use CM parameters
2716
+ if fs == 'custom' :
2717
+ fs = 'cm'
2718
+
2699
2719
if napostrophes :
2700
2720
if super is None :
2701
2721
super = Hlist ([])
@@ -2732,35 +2752,35 @@ def subsuper(self, s, loc, toks):
2732
2752
return [result ]
2733
2753
2734
2754
# Handle regular sub/superscripts
2735
- shift_up = nucleus .height - SUBDROP * xHeight
2755
+ shift_up = nucleus .height - SUBDROP [ fs ] * xHeight
2736
2756
if self .is_dropsub (nucleus ):
2737
- shift_down = nucleus .depth + SUBDROP * xHeight
2757
+ shift_down = nucleus .depth + SUBDROP [ fs ] * xHeight
2738
2758
else :
2739
- shift_down = SUBDROP * xHeight
2759
+ shift_down = SUBDROP [ fs ] * xHeight
2740
2760
if super is None :
2741
2761
# node757
2742
2762
x = Hlist ([sub ])
2743
2763
x .shrink ()
2744
- x .width += SCRIPT_SPACE * xHeight
2745
- shift_down = max (shift_down , SUB1 )
2746
- clr = x .height - (abs (xHeight * 4.0 ) / 5.0 )
2747
- shift_down = max (shift_down , clr )
2764
+ x .width += SCRIPT_SPACE [ fs ] * xHeight
2765
+ shift_down = max (shift_down , SUB1 [ fs ] * xHeight )
2766
+ # clr = x.height - (abs(xHeight * 4.0) / 5.0)
2767
+ # shift_down = max(shift_down, clr)
2748
2768
x .shift_amount = shift_down / 2.
2749
2769
else :
2750
2770
if self .is_slanted (last_char ):
2751
- x = Hlist ([Kern (DELTA * super .height ),super ])
2771
+ x = Hlist ([Kern (DELTA [ fs ] * super .height ),super ])
2752
2772
else :
2753
2773
x = Hlist ([super ])
2754
2774
x .shrink ()
2755
- x .width += SCRIPT_SPACE * xHeight
2756
- shift_up = SUP1 * xHeight
2775
+ x .width += SCRIPT_SPACE [ fs ] * xHeight
2776
+ shift_up = SUP1 [ fs ] * xHeight
2757
2777
if sub is None :
2758
2778
x .shift_amount = - shift_up
2759
2779
else : # Both sub and superscript
2760
2780
y = Hlist ([sub ])
2761
2781
y .shrink ()
2762
- y .width += SCRIPT_SPACE * xHeight
2763
- shift_down = max (shift_down , SUB1 * xHeight )
2782
+ y .width += SCRIPT_SPACE [ fs ] * xHeight
2783
+ shift_down = max (shift_down , SUB2 [ fs ] * xHeight )
2764
2784
# If sub and superscript collide, move sup up
2765
2785
clr = (2.0 * rule_thickness -
2766
2786
((shift_up - x .depth ) - (y .height - shift_down )))
0 commit comments