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

Skip to content

Commit 5b27064

Browse files
committed
Add boldsymbol functionalities
1 parent 59cb026 commit 5b27064

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2607,11 +2607,22 @@ def auto_delim(self, s, loc, toks):
26072607
def boldsymbol(self, s, loc, toks):
26082608
self.push_state()
26092609
state = self.get_state()
2610+
lw = list(map(chr, range(ord('a'), ord('z') + 1)))
2611+
up = list(map(chr, range(ord('A'), ord('Z') + 1)))
2612+
smGreek = list(map(lambda a: unicodedata.name(chr(a))
2613+
.split()[-1]
2614+
.lower(),
2615+
range(ord('\N{GREEK SMALL LETTER ALPHA}'),
2616+
ord('\N{GREEK SMALL LETTER OMEGA}') + 1)))
2617+
allLatin = [*lw, *up]
26102618
hlist = []
26112619
name = toks["value"]
26122620
for c in name:
26132621
if isinstance(c, Char):
2614-
c.font = "bsym"
2622+
c.font = "bf"
2623+
if str(c)[1] in allLatin or str(c)[2:-1] in smGreek:
2624+
c.font = "bfit"
2625+
c._update_metrics()
26152626
c._update_metrics()
26162627
hlist.append(c)
26172628
else:

lib/matplotlib/_mathtext_data.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,15 +1270,6 @@
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-
],
12821273
}
12831274

12841275

lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 1 deletion
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{abcde} \boldsymbol{\Gamma + \Omega} \boldsymbol{01234} \boldsymbol{\alpha * \beta}$',
137+
r'$\boldsymbol{abcde} \boldsymbol{+} \boldsymbol{\Gamma + \Omega} \boldsymbol{01234} \boldsymbol{\alpha * \beta}$',
138138
]
139139

140140
digits = "0123456789"

0 commit comments

Comments
 (0)