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

Skip to content

Commit efdcfc2

Browse files
authored
Merge pull request #20818 from QuLogic/fix-stix-glyphs
Swap Cap/Cup glyphs when using STIX font.
2 parents 0ed30ad + 4b7e07e commit efdcfc2

File tree

6 files changed

+140
-108
lines changed

6 files changed

+140
-108
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import matplotlib as mpl
2121
from . import _api, cbook
2222
from ._mathtext_data import (
23-
latex_to_bakoma, latex_to_standard, stix_virtual_fonts, tex2uni)
23+
latex_to_bakoma, latex_to_standard, stix_glyph_fixes, stix_virtual_fonts,
24+
tex2uni)
2425
from .afm import AFM
2526
from .font_manager import FontProperties, findfont, get_font
2627
from .ft2font import KERNING_DEFAULT
@@ -720,6 +721,10 @@ def _map_virtual_font(self, fontname, font_class, uniindex):
720721
uniindex = 0x1
721722
fontname = mpl.rcParams['mathtext.default']
722723

724+
# Fix some incorrect glyphs.
725+
if fontname in ('rm', 'it'):
726+
uniindex = stix_glyph_fixes.get(uniindex, uniindex)
727+
723728
# Handle private use area glyphs
724729
if fontname in ('it', 'rm', 'bf') and 0xe000 <= uniindex <= 0xf8ff:
725730
fontname = 'nonuni' + fontname

lib/matplotlib/_mathtext_data.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,3 +1384,11 @@
13841384
(0x0061, 0x007a, 'rm', 0x1d68a) # a-z
13851385
],
13861386
}
1387+
1388+
1389+
# Fix some incorrect glyphs.
1390+
stix_glyph_fixes = {
1391+
# Cap and Cup glyphs are swapped.
1392+
0x22d2: 0x22d3,
1393+
0x22d3: 0x22d2,
1394+
}
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_dejavusans_71.svg

Lines changed: 125 additions & 106 deletions
Loading

lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
r"$\left\Vert a \right\Vert \left\vert b \right\vert \left| a \right| \left\| b\right\| \Vert a \Vert \vert b \vert$",
104104
r'$\mathring{A} \AA$',
105105
r'$M \, M \thinspace M \/ M \> M \: M \; M \ M \enspace M \quad M \qquad M \! M$',
106-
r'$\Cup$ $\Cap$ $\leftharpoonup$ $\barwedge$ $\rightharpoonup$',
106+
r'$\Cap$ $\Cup$ $\leftharpoonup$ $\barwedge$ $\rightharpoonup$',
107107
r'$\dotplus$ $\doteq$ $\doteqdot$ $\ddots$',
108108
r'$xyz^kx_kx^py^{p-2} d_i^jb_jc_kd x^j_i E^0 E^0_u$', # github issue #4873
109109
r'${xyz}^k{x}_{k}{x}^{p}{y}^{p-2} {d}_{i}^{j}{b}_{j}{c}_{k}{d} {x}^{j}_{i}{E}^{0}{E}^0_u$',

0 commit comments

Comments
 (0)