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

Skip to content

Commit 2cfd449

Browse files
committed
Add sgreek and latin alphabets as set
1 parent 2593cf2 commit 2cfd449

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,11 @@ class _MathStyle(enum.Enum):
18121812
_right_delims = set(r") ] \} > \rfloor \rangle \rceil".split())
18131813
_delims = _left_delims | _right_delims | _ambi_delims
18141814

1815+
_small_greek = set([unicodedata.name(chr(i)).split()[-1].lower() for i in
1816+
range(ord('\N{GREEK SMALL LETTER ALPHA}'),
1817+
ord('\N{GREEK SMALL LETTER OMEGA}') + 1)])
1818+
_latin_alphabets = set(string.ascii_letters)
1819+
18151820
def __init__(self):
18161821
p = types.SimpleNamespace()
18171822

@@ -2630,10 +2635,6 @@ def auto_delim(self, s, loc, toks):
26302635
def boldsymbol(self, s, loc, toks):
26312636
self.push_state()
26322637
state = self.get_state()
2633-
small_greek = [unicodedata.name(chr(i)).split()[-1].lower() for i in
2634-
range(ord('\N{GREEK SMALL LETTER ALPHA}'),
2635-
ord('\N{GREEK SMALL LETTER OMEGA}') + 1)]
2636-
latin_alphabets = string.ascii_letters
26372638
hlist = []
26382639
name = toks["value"]
26392640
for c in name:
@@ -2642,9 +2643,11 @@ def boldsymbol(self, s, loc, toks):
26422643
if isinstance(k, Char):
26432644
k.font = "bf"
26442645
k._update_metrics()
2645-
if isinstance(c, Char):
2646+
hlist.append(c)
2647+
elif isinstance(c, Char):
26462648
c.font = "bf"
2647-
if c.c in latin_alphabets or c.c[1:] in small_greek:
2649+
if (c.c in self._latin_alphabets or
2650+
c.c[1:] in self._small_greek):
26482651
c.font = "bfit"
26492652
c._update_metrics()
26502653
c._update_metrics()

0 commit comments

Comments
 (0)