@@ -2662,6 +2662,19 @@ def is_slanted(self, nucleus):
2662
2662
return nucleus .is_slanted ()
2663
2663
return False
2664
2664
2665
+ def _get_fontset_name (self ):
2666
+ fs = rcParams ['mathtext.fontset' ]
2667
+ # If a custom fontset is used, check if it is Arev Sans, otherwise use
2668
+ # CM parameters.
2669
+ if fs == 'custom' :
2670
+ if (rcParams ['mathtext.rm' ] == 'sans' and
2671
+ rcParams ['font.sans-serif' ][0 ].lower () == 'Arev Sans' .lower ()):
2672
+ fs = 'arevsans'
2673
+ else :
2674
+ fs = 'cm'
2675
+
2676
+ return fs
2677
+
2665
2678
def subsuper (self , s , loc , toks ):
2666
2679
assert (len (toks )== 1 )
2667
2680
@@ -2759,15 +2772,15 @@ def subsuper(self, s, loc, toks):
2759
2772
result = Hlist ([vlist ])
2760
2773
return [result ]
2761
2774
2762
- # We remove kerning for consistency (otherwise it will compute kerning
2763
- # based on non-shrinked characters and may put them very close together
2764
- # when superscripted)
2775
+ # We remove kerning on the last character for consistency (otherwise it
2776
+ # will compute kerning based on non-shrinked characters and may put them
2777
+ # too close together when superscripted)
2765
2778
# We change the width of the last character to match the advance to
2766
2779
# consider some fonts with weird metrics: e.g. stix's f has a width of
2767
2780
# 7.75 and a kerning of -4.0 for an advance of 3.72, and we want to put
2768
2781
# the superscript at the advance
2769
2782
last_char = nucleus
2770
- if isinstance (nucleus ,Hlist ):
2783
+ if isinstance (nucleus , Hlist ):
2771
2784
new_children = nucleus .children
2772
2785
if len (new_children ):
2773
2786
# remove last kern
@@ -2781,17 +2794,10 @@ def subsuper(self, s, loc, toks):
2781
2794
last_char .width = last_char ._metrics .advance
2782
2795
nucleus = Hlist ([nucleus ])
2783
2796
2784
- fs = rcParams ['mathtext.fontset' ]
2785
- # If a custom fontset is used, check if it is Arev Sans, otherwise use
2786
- # CM parameters.
2787
- if fs == 'custom' :
2788
- if (rcParams ['mathtext.rm' ] == 'sans' and
2789
- rcParams ['font.sans-serif' ][0 ].lower () == 'Arev Sans' .lower ()):
2790
- fs = 'arevsans'
2791
- else :
2792
- fs = 'cm'
2793
-
2794
2797
# Handle regular sub/superscripts
2798
+
2799
+ fs = self ._get_fontset_name ()
2800
+
2795
2801
lc_height = last_char .height
2796
2802
lc_baseline = 0
2797
2803
if self .is_dropsub (last_char ):
0 commit comments