Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 686dffa

Browse files
committed
Mathtext spaces must be independent of font style.
1 parent f3593ae commit 686dffa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎lib/matplotlib/_mathtext.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,13 +1935,17 @@ def non_math(self, s, loc, toks):
19351935
float_literal = staticmethod(pyparsing_common.convertToFloat)
19361936

19371937
def _make_space(self, percentage):
1938-
# All spaces are relative to em width
1938+
# In TeX, an em (the unit usually used to measure horizontal lengths)
1939+
# is not the width of the character 'm'; it is the same in different
1940+
# font styles (e.g. roman or italic). Mathtext, however, uses 'm' in
1941+
# the italic style so that horizontal spaces don't depend on the
1942+
# current font style.
19391943
state = self.get_state()
19401944
key = (state.font, state.fontsize, state.dpi)
19411945
width = self._em_width_cache.get(key)
19421946
if width is None:
19431947
metrics = state.font_output.get_metrics(
1944-
state.font, mpl.rcParams['mathtext.default'], 'm',
1948+
'it', mpl.rcParams['mathtext.default'], 'm',
19451949
state.fontsize, state.dpi)
19461950
width = metrics.advance
19471951
self._em_width_cache[key] = width

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /