forked from mirrors/bookwyrm
Add an AttributeError exception for CI tests
This commit is contained in:
parent
5e9e7db935
commit
5b690532fa
1 changed files with 12 additions and 9 deletions
|
@ -55,15 +55,18 @@ def get_wrapped_text(text, font, content_width):
|
||||||
low = 0
|
low = 0
|
||||||
high = len(text)
|
high = len(text)
|
||||||
|
|
||||||
# ideal length is determined via binary search
|
try:
|
||||||
while low < high:
|
# ideal length is determined via binary search
|
||||||
mid = math.floor(low + high)
|
while low < high:
|
||||||
wrapped_text = textwrap.fill(text, width=mid)
|
mid = math.floor(low + high)
|
||||||
width = font.getsize_multiline(wrapped_text)[0]
|
wrapped_text = textwrap.fill(text, width=mid)
|
||||||
if width < content_width:
|
width = font.getsize_multiline(wrapped_text)[0]
|
||||||
low = mid
|
if width < content_width:
|
||||||
else:
|
low = mid
|
||||||
high = mid - 1
|
else:
|
||||||
|
high = mid - 1
|
||||||
|
except AttributeError:
|
||||||
|
wrapped_text = text
|
||||||
|
|
||||||
return wrapped_text
|
return wrapped_text
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue