Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mathtext spaces must be independent of font style. #23482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2022
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