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:
Kovid Goyal 2010-07-02 12:43:14 -06:00
parent 684f51b959
commit 58407a4445

View File

@ -65,6 +65,9 @@ class TextLine(object):
self.bottom_margin = bottom_margin self.bottom_margin = bottom_margin
self.font_path = font_path self.font_path = font_path
def __repr__(self):
return u'TextLine:%r:%f'%(self.text, self.font_size)
def alloc_wand(name): def alloc_wand(name):
ans = getattr(p, name)() ans = getattr(p, name)()
if ans < 0: if ans < 0:
@ -120,6 +123,10 @@ def draw_centered_text(img, dw, text, top, margin=10):
tokens = text.split(' ') tokens = text.split(' ')
while tokens: while tokens:
line, tokens = _get_line(img, dw, tokens, img_width-2*margin) 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) bottom = draw_centered_line(img, dw, ' '.join(line), top)
top = bottom top = bottom
return top return top