8000 Remove the use_cmex font fallback mechanism. by anntzer · Pull Request #18721 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Remove the use_cmex font fallback mechanism. #18721

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
Oct 13, 2020

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Oct 13, 2020

The use_cmex flag and latex_to_cmex table is a
fallback-to-computermodern mathtext system that is strictly less
powerful than the mathtext.fallback_to_cm (now mathtext.fallback)
system. Also, the latex_to_cmex table was incomplete.

Previously, with something like

rcParams["mathtext.fontset"] = "custom"; figtext(.5, .5, r"$\leftangle\langle$")

\leftangle would get unconditionally replaced by a Computer Modern
glyph, whereas \langle would stay as DejaVu Sans (as DejaVu provides
that glyph). With this patch, both glyphs now use DejaVu.

Conversely, if one forces the use of a font which does not contain the
\langle glyph (e.g. adding rcParams["mathtext.rm"] = "Comic Sans MS"), then both \leftangle and \langle get substituted to use
Computer Modern; this is not changed by this PR (except that now both
fallbacks can be controlled by rcParams["mathtext.fallback"].

latex_to_cmex and use_cmex were marked as deprecated, but with no
actual deprecation machinery as they can all go away once mathtext
fully goes private anyways.

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and pydocstyle<4 and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality is gone. This should get an API-Change note.

@@ -452,7 +451,7 @@ class UnicodeFonts(TruetypeFonts):
This class will "fallback" on the Bakoma fonts when a required
symbol can not be found in the font.
"""
use_cmex = True
use_cmex = True # Deprecated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is more helpful for us in the future:

Suggested change
use_cmex = True # Deprecated.
use_cmex = True # Unused. Delete once matplotlib.mathtext is private.

Same comment should be used below as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

@anntzer
Copy link
Contributor Author
anntzer commented Oct 13, 2020

It's not gone, fallback still works (as long as you have mathtext.fallback set, which is the default; if you disable fallback you (should) likely know what you're doing...).

The `use_cmex` flag and `latex_to_cmex` table is a
fallback-to-computermodern mathtext system that is strictly less
powerful than the `mathtext.fallback_to_cm` (now `mathtext.fallback`)
system.  Also, the `latex_to_cmex` table was incomplete.

Previously, with something like
```
rcParams["mathtext.fontset"] = "custom"; figtext(.5, .5, r"$\leftangle\langle$")
```
`\leftangle` would get unconditionally replaced by a Computer Modern
glyph, whereas `\langle` would stay as DejaVu Sans (as DejaVu provides
that glyph).  With this patch, both glyphs now use DejaVu.

Conversely, if one forces the use of a font which does not contain the
`\langle` glyph (e.g. adding `rcParams["mathtext.rm"] = "Comic Sans
MS"`), then both `\leftangle` and `\langle` get substituted to use
Computer Modern; this is not changed by this PR (except that now *both*
fallbacks can be controlled by `rcParams["mathtext.fallback"]`.

`latex_to_cmex` and `use_cmex` were marked as deprecated, but with no
actual deprecation machinery as they can all go away once `mathtext`
fully goes private anyways.
@dopplershift dopplershift merged commit 9a65a7d into matplotlib:master Oct 13, 2020
@QuLogic QuLogic added this to the v3.4.0 milestone Oct 13, 2020
@anntzer anntzer deleted the latex_to_cmex branch October 13, 2020 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0