Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,13 +1935,17 @@ def non_math(self, s, loc, toks):
float_literal = staticmethod(pyparsing_common.convertToFloat)

def _make_space(self, percentage):
# All spaces are relative to em width
# In TeX, an em (the unit usually used to measure horizontal lengths)
# is not the width of the character 'm'; it is the same in different
# font styles (e.g. roman or italic). Mathtext, however, uses 'm' in
# the italic style so that horizontal spaces don't depend on the
# current font style.
state = self.get_state()
key = (state.font, state.fontsize, state.dpi)
width = self._em_width_cache.get(key)
if width is None:
metrics = state.font_output.get_metrics(
state.font, mpl.rcParams['mathtext.default'], 'm',
'it', mpl.rcParams['mathtext.default'], 'm',
state.fontsize, state.dpi)
width = metrics.advance
self._em_width_cache[key] = width
Expand Down