mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 20:24:49 +02:00
Fix infinite loop in default cover generation. Fixes #6061 (0.7.6 "calibre-parallel.exe has stopped working" when converting from some PDFs to epub)
This commit is contained in:
parent
684f51b959
commit
58407a4445
1 changed files with 7 additions and 0 deletions
|
|
@ -65,6 +65,9 @@ def __init__(self, text, font_size, bottom_margin=30, font_path=None):
|
|||
self.bottom_margin = bottom_margin
|
||||
self.font_path = font_path
|
||||
|
||||
def __repr__(self):
|
||||
return u'TextLine:%r:%f'%(self.text, self.font_size)
|
||||
|
||||
def alloc_wand(name):
|
||||
ans = getattr(p, name)()
|
||||
if ans < 0:
|
||||
|
|
@ -120,6 +123,10 @@ def draw_centered_text(img, dw, text, top, margin=10):
|
|||
tokens = text.split(' ')
|
||||
while tokens:
|
||||
line, tokens = _get_line(img, dw, tokens, img_width-2*margin)
|
||||
if not line:
|
||||
# Could not fit the first token on the line
|
||||
line = tokens[:1]
|
||||
tokens = tokens[1:]
|
||||
bottom = draw_centered_line(img, dw, ' '.join(line), top)
|
||||
top = bottom
|
||||
return top
|
||||
|
|
|
|||
Loading…
Reference in a new issue