Skip to content

Commit c8fee9e

Browse files
committed
fix overunder
1 parent b62d117 commit c8fee9e

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

lib/matplotlib/mathtext.py

+32-32
Original file line numberDiff line numberDiff line change
@@ -2718,44 +2718,12 @@ def subsuper(self, s, loc, toks):
27182718
"Subscript/superscript sequence is too long. "
27192719
"Use braces { } to remove ambiguity.")
27202720

2721-
# We remove kerning for consistency (otherwise it will compute kerning
2722-
# based on non-shrinked characters and may put them very close together
2723-
# when superscripted)
2724-
# We change the width of the last character to match the advance to
2725-
# consider some fonts with weird metrics: e.g. stix's f has a width of
2726-
# 7.75 and a kerning of -4.0 for an advance of 3.72, and we want to put
2727-
# the superscript at the advance
2728-
last_char = nucleus
2729-
if isinstance(nucleus,Hlist):
2730-
new_children = nucleus.children
2731-
if len(new_children):
2732-
# remove last kern
2733-
if isinstance(new_children[-1],Kern):
2734-
new_children = new_children[:-1]
2735-
last_char = new_children[-1]
2736-
last_char.width = last_char._metrics.advance
2737-
# create new Hlist without kerning
2738-
nucleus = Hlist(new_children, do_kern=False)
2739-
else:
2740-
last_char.width = last_char._metrics.advance
2741-
nucleus = Hlist([nucleus])
2742-
27432721
state = self.get_state()
27442722
rule_thickness = state.font_output.get_underline_thickness(
27452723
state.font, state.fontsize, state.dpi)
27462724
xHeight = state.font_output.get_xheight(
27472725
state.font, state.fontsize, state.dpi)
27482726

2749-
fs = rcParams['mathtext.fontset']
2750-
# If a custom fontset is used, check if it is Arev Sans, otherwise use
2751-
# CM parameters.
2752-
if fs == 'custom':
2753-
if (rcParams['mathtext.rm'] == 'sans' and
2754-
rcParams['font.sans-serif'][0].lower() == 'Arev Sans'.lower()):
2755-
fs = 'arevsans'
2756-
else:
2757-
fs = 'cm'
2758-
27592727
if napostrophes:
27602728
if super is None:
27612729
super = Hlist([])
@@ -2791,6 +2759,38 @@ def subsuper(self, s, loc, toks):
27912759
result = Hlist([vlist])
27922760
return [result]
27932761

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)
2765+
# We change the width of the last character to match the advance to
2766+
# consider some fonts with weird metrics: e.g. stix's f has a width of
2767+
# 7.75 and a kerning of -4.0 for an advance of 3.72, and we want to put
2768+
# the superscript at the advance
2769+
last_char = nucleus
2770+
if isinstance(nucleus,Hlist):
2771+
new_children = nucleus.children
2772+
if len(new_children):
2773+
# remove last kern
2774+
if isinstance(new_children[-1],Kern):
2775+
new_children = new_children[:-1]
2776+
last_char = new_children[-1]
2777+
last_char.width = last_char._metrics.advance
2778+
# create new Hlist without kerning
2779+
nucleus = Hlist(new_children, do_kern=False)
2780+
else:
2781+
last_char.width = last_char._metrics.advance
2782+
nucleus = Hlist([nucleus])
2783+
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+
27942794
# Handle regular sub/superscripts
27952795
lc_height = last_char.height
27962796
lc_baseline = 0

0 commit comments

Comments
 (0)