Skip to content

Commit 05beecd

Browse files
committed
Update logic and baseline images
1 parent d8a1238 commit 05beecd

31 files changed

+79
-81
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,26 +2888,24 @@ def _genset(self, state, value, symbol, shift):
28882888
cvalue.hpack(width, 'exactly')
28892889
csymbol.hpack(width, 'exactly')
28902890

2891+
metrics = state.font_output.get_metrics(
2892+
state.font, mpl.rcParams['mathtext.default'],
2893+
r'\leftrightarrow', state.fontsize, state.dpi)
2894+
2895+
# Shift so the symbol sits in the same horizontal position
2896+
shift_amount = (csymbol.height)/2. - (metrics.ymax + metrics.ymin)/2.
28912897
if shift:
2892-
vlist = Vlist([csymbol, # symbol
2893-
Vbox(0, thickness * 2.), # space
2894-
cvalue # value
2898+
vlist = Vlist([csymbol, # value
2899+
cvalue # symbol
28952900
])
2896-
2897-
# Shift so the symbol sits in the same horizontal position
2898-
metrics = state.font_output.get_metrics(
2899-
state.font, mpl.rcParams['mathtext.default'],
2900-
r'\rightarrow', state.fontsize, state.dpi)
2901-
2902-
shift = ((csymbol.height) / 2. +
2903-
(metrics.ymax + metrics.ymin) / 2. + thickness * 2.)
2904-
2905-
vlist.shift_amount = shift
2901+
vlist.shift_amount = shift_amount + cvalue.height
29062902
else:
29072903
vlist = Vlist([cvalue, # value
2908-
Vbox(0, thickness * 2.), # space
2904+
Vbox(0, thickness * 1.5), # space
29092905
csymbol # symbol
29102906
])
2907+
vlist.shift_amount = shift_amount
2908+
29112909
hlist = [Hlist([vlist, Hbox(thickness * 2.)])]
29122910

29132911
return hlist
Binary file not shown.
0 Bytes
Loading

lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_83.svg

Lines changed: 7 additions & 7 deletions
Loading
Binary file not shown.
-22 Bytes
Loading

lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_84.svg

Lines changed: 6 additions & 6 deletions
Loading
Binary file not shown.
3 Bytes
Loading

lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_dejavusans_83.svg

Lines changed: 7 additions & 7 deletions
Loading

0 commit comments

Comments
 (0)