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

Skip to content

Commit 59cb026

Browse files
committed
Add boldsymbol functionality in mathtext
1 parent 82f969c commit 59cb026

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,12 +2607,11 @@ def auto_delim(self, s, loc, toks):
26072607
def boldsymbol(self, s, loc, toks):
26082608
self.push_state()
26092609
state = self.get_state()
2610-
state.font = 'bfit'
26112610
hlist = []
26122611
name = toks["value"]
26132612
for c in name:
26142613
if isinstance(c, Char):
2615-
c.font = 'bfit'
2614+
c.font = "bsym"
26162615
c._update_metrics()
26172616
hlist.append(c)
26182617
else:

lib/matplotlib/_mathtext_data.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,15 @@
12701270
(0x0041, 0x005a, 'rm', 0x1d670), # A-Z
12711271
(0x0061, 0x007a, 'rm', 0x1d68a) # a-z
12721272
],
1273+
'bsym':
1274+
[
1275+
(0x0030, 0x0039, 'bf', 0x1d7ec), # 0-9
1276+
(0x0041, 0x005a, 'bfit', 0x1d63c), # A-Z
1277+
(0x0061, 0x007a, 'bfit', 0x1d656), # a-z
1278+
(0x0393, 0x03a9, 'bf', 0x1d758), # \Gamma-Omega
1279+
(0x2207, 0x2207, 'bf', 0x1d76f), # \Nabla
1280+
(0x03b1, 0x03c9, 'bf', 0x1d770), # \alpha-\omega
1281+
],
12731282
}
12741283

12751284

lib/matplotlib/tests/test_mathtext.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
r'$\sum x\quad\sum^nx\quad\sum_nx\quad\sum_n^nx\quad\prod x\quad\prod^nx\quad\prod_nx\quad\prod_n^nx$', # GitHub issue 18085
135135
r'$1.$ $2.$ $19680801.$ $a.$ $b.$ $mpl.$',
136136
r'$\text{text}_{\text{sub}}^{\text{sup}} + \text{\$foo\$} + \frac{\text{num}}{\mathbf{\text{den}}}\text{with space, curly brackets \{\}, and dash -}$',
137-
r'$\boldsymbol{boldsymbol} \boldsymbol{\alpha} \boldsymbol{01234} \boldsymbol{\alpha * \beta}$',
137+
r'$\boldsymbol{abcde} \boldsymbol{\Gamma + \Omega} \boldsymbol{01234} \boldsymbol{\alpha * \beta}$',
138138
]
139139

140140
digits = "0123456789"
@@ -542,6 +542,5 @@ def test_mathtext_operators():
542542

543543
@check_figures_equal(extensions=["png"])
544544
def test_boldsymbol(fig_test, fig_ref):
545-
fig_test.text(0.1, 0.2, r"$\boldsymbol{\mathrm{abc0123\alpha}}")
546-
547-
fig_ref.text(0.1, 0.2, r"$\mathrm{abc0123\alpha}")
545+
fig_test.text(0.1, 0.2, r"$\boldsymbol{\mathrm{abc0123\alpha}}$")
546+
fig_ref.text(0.1, 0.2, r"$\mathrm{abc0123\alpha}$")

0 commit comments

Comments
 (0)