mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2018698 [Toolbar button wordwrap glitch](https://bugs.launchpad.net/calibre/+bug/2018698)
This commit is contained in:
parent
4f44527eb1
commit
a2a0848bb1
@ -85,7 +85,13 @@ def wrap_button_text(text, max_len=MAX_TEXT_LENGTH):
|
|||||||
broken = True
|
broken = True
|
||||||
else:
|
else:
|
||||||
ans = word
|
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:
|
if ' ' in ans:
|
||||||
ans = '\n'.join(ans.split(' ', 1))
|
ans = '\n'.join(ans.split(' ', 1))
|
||||||
elif '/' in ans:
|
elif '/' in ans:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user