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

Skip to content

Commit c2fa7ba

Browse files
anntzerQuLogic
authored andcommitted
Fix positioning of wide mathtext accents.
A wide accent over more than one character should just be centered over the underlying box. In any case this works better than the current strategy of shifting by an amount depending on the box's width (which results in absurdly large shifts for wide boxes). When positioning over a single character the behavior is different -- TeX uses specific font metrics info for that case, and we can try rendering as combining characters instead (not done in this PR).
1 parent d57abf4 commit c2fa7ba

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/matplotlib/_mathtext.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,12 +2324,13 @@ def accent(self, toks: ParseResults) -> T.Any:
23242324
if accent in self._wide_accents:
23252325
accent_box = AutoWidthChar(
23262326
'\\' + accent, sym.width, state, char_class=Accent)
2327+
centered = HCentered([accent_box])
23272328
else:
23282329
accent_box = Accent(self._accent_map[accent], state)
2329-
if accent == 'mathring':
2330-
accent_box.shrink()
2331-
accent_box.shrink()
2332-
centered = HCentered([Hbox(sym.width / 4.0), accent_box])
2330+
if accent == 'mathring':
2331+
accent_box.shrink()
2332+
accent_box.shrink()
2333+
centered = HCentered([Hbox(sym.width / 4.0), accent_box])
23332334
centered.hpack(sym.width, 'exactly')
23342335
return Vlist([
23352336
centered,

0 commit comments

Comments
 (0)