@@ -1187,13 +1187,13 @@ 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 = {'cm' : 0.03 ,
1190
+ SCRIPT_SPACE = {'cm' : 0.05 ,
1191
1191
'stix' : 0.10 ,
1192
1192
'stixsans' : 0.10 }
1193
1193
## Percentage of x-height that sub/superscripts drop below the baseline
1194
1194
SUBDROP = {'cm' : 0.3 ,
1195
- 'stix' : 0.3 ,
1196
- 'stixsans' : 0.3 }
1195
+ 'stix' : 0.4 ,
1196
+ 'stixsans' : 0.4 }
1197
1197
# Percentage of x-height that superscripts drop below the baseline
1198
1198
SUP1 = {'cm' : 0.4 ,
1199
1199
'stix' : 0.8 ,
@@ -1212,6 +1212,11 @@ def get_underline_thickness(self, font, fontsize, dpi):
1212
1212
DELTA = {'cm' : 0.10 ,
1213
1213
'stix' : 0.15 ,
1214
1214
'stixsans' : 0.25 }
1215
+ # Percentage of x-height that supercripts are offset relative to the subscript
1216
+ # for integrals
1217
+ DELTAINTEGRAL = {'cm' : 0.5 ,
1218
+ 'stix' : 0.5 ,
1219
+ 'stixsans' : 0.4 }
1215
1220
1216
1221
class MathTextWarning (Warning ):
1217
1222
pass
@@ -2752,35 +2757,53 @@ def subsuper(self, s, loc, toks):
2752
2757
return [result ]
2753
2758
2754
2759
# Handle regular sub/superscripts
2755
- shift_up = nucleus .height - SUBDROP [fs ] * xHeight
2756
- if self .is_dropsub (nucleus ):
2757
- shift_down = nucleus .depth + SUBDROP [fs ] * xHeight
2758
- else :
2759
- shift_down = SUBDROP [fs ] * xHeight
2760
+ lc_height = last_char .height
2761
+ lc_baseline = 0
2762
+ if self .is_dropsub (last_char ):
2763
+ lc_baseline = last_char .depth
2760
2764
if super is None :
2761
2765
# node757
2762
- x = Hlist ([sub ])
2766
+ if self .is_dropsub (last_char ):
2767
+ x = Hlist ([Kern (- DELTA [fs ] * last_char .height ),sub ])
2768
+ else :
2769
+ x = Hlist ([sub ])
2763
2770
x .shrink ()
2764
2771
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)
2768
- x .shift_amount = shift_down / 2.
2772
+ shift_down = max (lc_baseline + SUBDROP [fs ] * xHeight ,
2773
+ SUB1 [fs ] * xHeight )
2774
+ if not self .is_dropsub (last_char ):
2775
+ shift_down /= 2
2776
+ x .shift_amount = shift_down
2769
2777
else :
2778
+ if self .is_dropsub (last_char ):
2779
+ delta = DELTAINTEGRAL [fs ]
2780
+ else :
2781
+ delta = DELTA [fs ]
2782
+
2770
2783
if self .is_slanted (last_char ):
2771
- x = Hlist ([Kern (DELTA [ fs ] * super .height ),super ])
2784
+ x = Hlist ([Kern (delta * last_char .height ),super ])
2772
2785
else :
2773
2786
x = Hlist ([super ])
2774
2787
x .shrink ()
2775
2788
x .width += SCRIPT_SPACE [fs ] * xHeight
2776
- shift_up = SUP1 [fs ] * xHeight
2789
+ if self .is_dropsub (last_char ):
2790
+ shift_up = lc_height - SUBDROP [fs ] * xHeight
2791
+ else :
2792
+ shift_up = SUP1 [fs ] * xHeight
2777
2793
if sub is None :
2778
2794
x .shift_amount = - shift_up
2779
2795
else : # Both sub and superscript
2780
- y = Hlist ([sub ])
2796
+ if self .is_dropsub (last_char ):
2797
+ y = Hlist ([Kern (- DELTA [fs ] * last_char .height ),sub ])
2798
+ else :
2799
+ y = Hlist ([sub ])
2800
+ #y = Hlist([sub])
2781
2801
y .shrink ()
2782
2802
y .width += SCRIPT_SPACE [fs ] * xHeight
2783
- shift_down = max (shift_down , SUB2 [fs ] * xHeight )
2803
+ if self .is_dropsub (last_char ):
2804
+ shift_down = lc_baseline + SUBDROP [fs ] * xHeight
2805
+ else :
2806
+ shift_down = SUB2 [fs ] * xHeight
2784
2807
# If sub and superscript collide, move sup up
2785
2808
clr = (2.0 * rule_thickness -
2786
2809
((shift_up - x .depth ) - (y .height - shift_down )))
0 commit comments