Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit897487e

Browse files
committed
Add support for more accents in mathtext
1 parentfd4cce7 commit897487e

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

‎lib/matplotlib/_mathtext.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,6 +2031,9 @@ def unknown_symbol(self, s, loc, toks):
20312031
r'overrightarrow':r'\rightarrow',
20322032
r'overleftarrow':r'\leftarrow',
20332033
r'mathring':r'\circ',
2034+
r'=':r'\combiningoverline',
2035+
r'H':r'\combiningdoubleacuteaccent',
2036+
r'check':r'\combiningcaron',
20342037
}
20352038

20362039
_wide_accents=set(r"widehat widetilde widebar".split())
@@ -2050,8 +2053,18 @@ def accent(self, s, loc, toks):
20502053
accent_box=AutoWidthChar(
20512054
'\\'+accent,sym.width,state,char_class=Accent)
20522055
else:
2056+
# Check if accent and character can be combined
2057+
a=get_unicode_index(self._accent_map[accent])
2058+
ifisinstance(sym,Char):
2059+
c=sym.c
2060+
else:
2061+
c=sym.children[0].c
2062+
comb=unicodedata.normalize('NFC',c+chr(a))
2063+
iflen(comb)==1:
2064+
returnChar(comb,state)
2065+
# Cannot be combined
20532066
accent_box=Accent(self._accent_map[accent],state)
2054-
ifaccent=='mathring':
2067+
ifaccentin ('mathring','r'):
20552068
accent_box.shrink()
20562069
accent_box.shrink()
20572070
centered=HCentered([Hbox(sym.width/4.0),accent_box])

‎lib/matplotlib/_mathtext_data.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,8 @@
10021002
'combiningdotabove' :775,
10031003
'combiningthreedotsabove' :8411,
10041004
'combiningfourdotsabove' :8412,
1005+
'combiningdoubleacuteaccent' :779,
1006+
'combiningcaron' :780,
10051007
'to' :8594,
10061008
'succeq' :8829,
10071009
'emptyset' :8709,

‎tutorials/text/mathtext.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@
306306
Command Result
307307
============================== =================================
308308
``\acute a`` or ``\'a`` :mathmpl:`\acute a`
309-
``\bar a`` :mathmpl:`\bar a`
309+
``\bar a``or ``\= a`` :mathmpl:`\bar a`
310310
``\breve a`` :mathmpl:`\breve a`
311311
``\dot a`` or ``\.a`` :mathmpl:`\dot a`
312312
``\ddot a`` or ``\''a`` :mathmpl:`\ddot a`
@@ -316,6 +316,8 @@
316316
``\hat a`` or ``\^a`` :mathmpl:`\hat a`
317317
``\tilde a`` or ``\~a`` :mathmpl:`\tilde a`
318318
``\vec a`` :mathmpl:`\vec a`
319+
``\check a`` :mathmpl:`\check a`
320+
``\H a`` :mathmpl:`\H a`
319321
``\overline{abc}`` :mathmpl:`\overline{abc}`
320322
============================== =================================
321323

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp