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

Appearance settings

Commit b1691d9

Browse filesBrowse files
committed
Remove the use_cmex font fallback mechanism.
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.
1 parent b2802b5 commit b1691d9
Copy full SHA for b1691d9

File tree

Expand file treeCollapse file tree

2 files changed

+12
-22
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-22
lines changed

‎lib/matplotlib/_mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext.py
+11-21Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
import matplotlib as mpl
2121
from . import cbook
2222
from ._mathtext_data import (
23-
latex_to_bakoma, latex_to_cmex, latex_to_standard, stix_virtual_fonts,
24-
tex2uni)
23+
latex_to_bakoma, latex_to_standard, stix_virtual_fonts, tex2uni)
2524
from .afm import AFM
2625
from .font_manager import FontProperties, findfont, get_font
2726
from .ft2font import KERNING_DEFAULT
@@ -452,7 +451,7 @@ class UnicodeFonts(TruetypeFonts):
452451
This class will "fallback" on the Bakoma fonts when a required
453452
symbol can not be found in the font.
454453
"""
455-
use_cmex = True
454+
use_cmex = True # Unused; delete once mathtext becomes private.
456455

457456
def __init__(self, *args, **kwargs):
458457
# This must come first so the backend's owner is set correctly
@@ -497,22 +496,13 @@ def _map_virtual_font(self, fontname, font_class, uniindex):
497496
return fontname, uniindex
498497

499498
def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
500-
found_symbol = False
501-
502-
if self.use_cmex:
503-
uniindex = latex_to_cmex.get(sym)
504-
if uniindex is not None:
505-
fontname = 'ex'
506-
found_symbol = True
507-
508-
if not found_symbol:
509-
try:
510-
uniindex = get_unicode_index(sym, math)
511-
found_symbol = True
512-
except ValueError:
513-
uniindex = ord('?')
514-
_log.warning(
515-
"No TeX to unicode mapping for {!a}.".format(sym))
499+
try:
500+
uniindex = get_unicode_index(sym, math)
501+
found_symbol = True
502+
except ValueError:
503+
uniindex = ord('?')
504+
found_symbol = False
505+
_log.warning("No TeX to unicode mapping for {!a}.".format(sym))
516506

517507
fontname, uniindex = self._map_virtual_font(
518508
fontname, font_class, uniindex)
@@ -574,7 +564,7 @@ def get_sized_alternatives_for_symbol(self, fontname, sym):
574564

575565

576566
class DejaVuFonts(UnicodeFonts):
577-
use_cmex = False
567+
use_cmex = False # Unused; delete once mathtext becomes private.
578568

579569
def __init__(self, *args, **kwargs):
580570
# This must come first so the backend's owner is set correctly
@@ -677,7 +667,7 @@ class StixFonts(UnicodeFonts):
677667
4: 'STIXSizeFourSym',
678668
5: 'STIXSizeFiveSym',
679669
}
680-
use_cmex = False
670+
use_cmex = False # Unused; delete once mathtext becomes private.
681671
cm_fallback = False
682672
_sans = False
683673

‎lib/matplotlib/_mathtext_data.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext_data.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
'\\_' : ('cmtt10', 0x5f)
237237
}
238238

239-
latex_to_cmex = {
239+
latex_to_cmex = { # Unused; delete once mathtext becomes private.
240240
r'\__sqrt__' : 112,
241241
r'\bigcap' : 92,
242242
r'\bigcup' : 91,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.