@@ -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.00 ,
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.00}
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
+ # subscript is present
1207
+ SUB2 = {'cm' : 0.3 ,
1208
+ 'stix' : 0.8 ,
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,15 @@ 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, try to infer what sort of font is being
2713
+ # used. If serif use stix parameters, if sans use stixsans.
2714
+ if fs == 'custom' :
2715
+ if 'sans' in rcParams ['mathtext.rm' ]:
2716
+ fs = 'stixsans'
2717
+ else :
2718
+ fs = 'stix'
2719
+
2696
2720
if napostrophes :
2697
2721
if super is None :
2698
2722
super = Hlist ([])
@@ -2729,35 +2753,36 @@ def subsuper(self, s, loc, toks):
2729
2753
return [result ]
2730
2754
2731
2755
# Handle regular sub/superscripts
2732
- shift_up = nucleus .height - SUBDROP * xHeight
2733
- if self .is_dropsub (nucleus ):
2734
- shift_down = nucleus .depth + SUBDROP * xHeight
2735
- else :
2736
- shift_down = SUBDROP * xHeight
2756
+ #shift_up = nucleus.height - SUBDROP[fs] * xHeight
2757
+ #if self.is_dropsub(nucleus):
2758
+ #shift_down = nucleus.depth + SUBDROP[fs] * xHeight
2759
+ #else:
2760
+ #shift_down = SUBDROP[fs] * xHeight
2761
+ shift_down , shift_up = 0 ,0
2737
2762
if super is None :
2738
2763
# node757
2739
2764
x = Hlist ([sub ])
2740
2765
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 )
2766
+ x .width += SCRIPT_SPACE [ fs ] * xHeight
2767
+ shift_down = max (shift_down , SUB1 [ fs ] * xHeight )
2768
+ # clr = x.height - (abs(xHeight * 4.0) / 5.0)
2769
+ # shift_down = max(shift_down, clr)
2745
2770
x .shift_amount = shift_down / 2.
2746
2771
else :
2747
2772
if self .is_slanted (last_char ):
2748
- x = Hlist ([Kern (DELTA * super .height ),super ])
2773
+ x = Hlist ([Kern (DELTA [ fs ] * super .height ),super ])
2749
2774
else :
2750
2775
x = Hlist ([super ])
2751
2776
x .shrink ()
2752
- x .width += SCRIPT_SPACE * xHeight
2753
- shift_up = SUP1 * xHeight
2777
+ x .width += SCRIPT_SPACE [ fs ] * xHeight
2778
+ shift_up = SUP1 [ fs ] * xHeight
2754
2779
if sub is None :
2755
2780
x .shift_amount = - shift_up
2756
2781
else : # Both sub and superscript
2757
2782
y = Hlist ([sub ])
2758
2783
y .shrink ()
2759
- y .width += SCRIPT_SPACE * xHeight
2760
- shift_down = max (shift_down , SUB1 * xHeight )
2784
+ y .width += SCRIPT_SPACE [ fs ] * xHeight
2785
+ shift_down = max (shift_down , SUB2 [ fs ] * xHeight )
2761
2786
# If sub and superscript collide, move sup up
2762
2787
clr = (2.0 * rule_thickness -
2763
2788
((shift_up - x .depth ) - (y .height - shift_down )))
0 commit comments