From c052186b188b3a00562288cddcc8bc9ed03e2b7c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 19 Jul 2014 00:53:11 +0530 Subject: [PATCH] When generating covers, do not render soft-hyphens in the text as hyphens. Fixes #1344259 [title contains softhyphens that only appear when generating title pages](https://bugs.launchpad.net/calibre/+bug/1344259) --- src/calibre/ebooks/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index 9eb2d61e07..595364694b 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -186,7 +186,9 @@ def calibre_cover(title, author_string, series_string=None, author_string = normalize(author_string) series_string = normalize(series_string) from calibre.utils.magick.draw import create_cover_page, TextLine - text = title + author_string + (series_string or u'') + import regex + pat = regex.compile(ur'\p{Cf}+', flags=regex.VERSION1) # remove non-printing chars like the soft hyphen + text = pat.sub(u'', title + author_string + (series_string or u'')) font_path = tweaks['generate_cover_title_font'] if font_path is None: font_path = P('fonts/liberation/LiberationSerif-Bold.ttf') @@ -203,10 +205,10 @@ def calibre_cover(title, author_string, series_string=None, font_path = pt.name cleanup = True - lines = [TextLine(title, title_size, font_path=font_path), - TextLine(author_string, author_size, font_path=font_path)] + lines = [TextLine(pat.sub(u'', title), title_size, font_path=font_path), + TextLine(pat.sub(u'', author_string), author_size, font_path=font_path)] if series_string: - lines.append(TextLine(series_string, author_size, font_path=font_path)) + lines.append(TextLine(pat.sub(u'', series_string), author_size, font_path=font_path)) if logo_path is None: logo_path = I('library.png') try: