FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Properly use thin space after math text operator by mpetroff · Pull Request #17890 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .pdf  (5) .png  (5) .py  (2) .svg  (5) All 4 file types selected
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
26 changes: 19 additions & 7 deletions lib/matplotlib/mathtext.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from pyparsing import (
Combine, Empty, FollowedBy, Forward, Group, Literal, oneOf, OneOrMore,
Optional, ParseBaseException, ParseFatalException, ParserElement,
QuotedString, Regex, StringEnd, Suppress, ZeroOrMore)
ParseResults, QuotedString, Regex, StringEnd, Suppress, ZeroOrMore)

from matplotlib import cbook, colors as mcolors, rcParams
from matplotlib.afm import AFM
Expand Down Expand Up @@ -2873,25 +2873,37 @@ def accent(self, s, loc, toks):
])

def function(self, s, loc, toks):
self.push_state()
state = self.get_state()
state.font = 'rm'
hlist = Hlist([Char(c, state) for c in toks[0]])
self.pop_state()
hlist = self.operatorname(s, loc, toks)
hlist.function_name = toks[0]
return hlist

def operatorname(self, s, loc, toks):
self.push_state()
state = self.get_state()
state.font = 'rm'
hlist_list = []
# Change the font of Chars, but leave Kerns alone
for c in toks[0]:
if isinstance(c, Char):
c.font = 'rm'
c._update_metrics()
hlist_list.append(c)
elif isinstance(c, str):
hlist_list.append(Char(c, state))
else:
hlist_list.append(c)
next_char_loc = loc + len(toks[0]) + 1
if isinstance(toks[0], ParseResults):
next_char_loc += len('operatorname{}')
next_char = next((c for c in s[next_char_loc:] if c != ' '), '')
delimiters = self._left_delim | self._ambi_delim | self._right_delim
delimiters |= {'^', '_'}
if (next_char not in delimiters and
toks[0] not in self._overunder_functions):
# Add thin space except when followed by parenthesis, bracket, etc.
hlist_list += [self._make_space(self._space_widths[r'\,'])]
self.pop_state()
return Hlist(toks[0])
return Hlist(hlist_list)

def start_group(self, s, loc, toks):
self.push_state()
Expand Down
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

Loading

Back | FazBrowse Home | New Git URL