10000 Fix Angstrom issues. · matplotlib/matplotlib@41e6c29 · GitHub
[go: up one dir, main page]

Skip to content

Commit 41e6c29

Browse files
committed
Fix Angstrom issues.
Add support for \mathring. Make \AA symbol match LaTeX.
1 parent 6e3471d commit 41e6c29

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

lib/matplotlib/_mathtext_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2281,7 +2281,7 @@
22812281
'obar' : 9021,
22822282
'supseteq' : 8839,
22832283
'nu' : 957,
2284-
'AA' : 8491,
2284+
'AA' : 197,
22852285
'AE' : 198,
22862286
'models' : 8871,
22872287
'ominus' : 8854,

lib/matplotlib/mathtext.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,7 +2475,7 @@ def unknown_symbol(self, s, loc, toks):
24752475
# The first 2 entires in the tuple are (font, char, sizescale) for
24762476
# the two symbols under and over. The third element is the space
24772477
# (in multiples of underline height)
2478-
r'AA' : ( ('rm', 'A', 1.0), (None, '\circ', 0.5), 0.0),
2478+
r'AA' : ( ('it', 'A', 1.0), (None, '\circ', 0.5), 0.0),
24792479
}
24802480

24812481
def c_over_c(self, s, loc, toks):
@@ -2532,7 +2532,8 @@ def c_over_c(self, s, loc, toks):
25322532
r'.' : r'\combiningdotabove',
25332533
r'^' : r'\circumflexaccent',
25342534
r'overrightarrow' : r'\rightarrow',
2535-
r'overleftarrow' : r'\leftarrow'
2535+
r'overleftarrow' : r'\leftarrow',
2536+
r'mathring' : r'\circ'
25362537
}
25372538

25382539
_wide_accents = set(r"widehat widetilde widebar".split())
@@ -2546,11 +2547,14 @@ def accent(self, s, loc, toks):
25462547
raise ParseFatalException("Error parsing accent")
25472548
accent, sym = toks[0]
25482549
if accent in self._wide_accents:
2549-
accent = AutoWidthChar(
2550+
accent_box = AutoWidthChar(
25502551
'\\' + accent, sym.width, state, char_class=Accent)
25512552
else:
2552-
accent = Accent(self._accent_map[accent], state)
2553-
centered = HCentered([accent])
2553+
accent_box = Accent(self._accent_map[accent], state)
2554+
if accent == 'mathring':
2555+
accent_box.shrink()
2556+
accent_box.shrink()
2557+
centered = HCentered([Hbox(sym.width / 4.0), accent_box])
25542558
centered.hpack(sym.width, 'exactly')
25552559
return Vlist([
25562560
centered,

lib/matplotlib/tests/test_mathtext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@
9393
r"$? ! &$", # github issue #466
9494
r'$\operatorname{cos} x$', # github issue #553
9595
r'$\sum _{\genfrac{}{}{0}{}{0\leq i\leq m}{0<j<n}}P\left(i,j\right)$',
96-
r"$\left\Vert a \right\Vert \left\vert b \right\vert \left| a \right| \left\| b\right\| \Vert a \Vert \vert b \vert$"
96+
r"$\left\Vert a \right\Vert \left\vert b \right\vert \left| a \right| \left\| b\right\| \Vert a \Vert \vert b \vert$",
97+
r'$\mathring{A} \stackrel{\circ}{A} \AA$'
9798
]
9899

99100
digits = "0123456789"

0 commit comments

Comments
 (0)
0