diff --git a/src/calibre/gui2/bars.py b/src/calibre/gui2/bars.py index c45cb779f7..7108eafedc 100644 --- a/src/calibre/gui2/bars.py +++ b/src/calibre/gui2/bars.py @@ -85,7 +85,13 @@ def wrap_button_text(text, max_len=MAX_TEXT_LENGTH): broken = True else: ans = word - if not broken: + if broken: + prefix, suffix = ans.split('\n', 1) + if len(suffix) > len(prefix) and len(suffix) > MAX_TEXT_LENGTH and len(prefix) < MAX_TEXT_LENGTH and suffix.count(' ') > 1: + word, rest = suffix.split(' ', 1) + if len(word) + len(prefix) <= len(rest): + ans = prefix + ' ' + word + '\n' + rest + else: if ' ' in ans: ans = '\n'.join(ans.split(' ', 1)) elif '/' in ans: