mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-29 18:43:58 +02:00
NFC normalize text before rendering in generated cover
This commit is contained in:
parent
70fa77177a
commit
e20672cf45
1 changed files with 7 additions and 0 deletions
|
|
@ -181,6 +181,7 @@ def draw(self, painter):
|
|||
|
||||
def layout_text(prefs, img, title, subtitle, footer, max_height, style):
|
||||
width = img.width() - 2 * style.hmargin
|
||||
title, subtitle, footer = map(normalize, (title, subtitle, footer))
|
||||
title_font = QFont(prefs.title_font_family or 'Liberation Serif')
|
||||
title_font.setPixelSize(prefs.title_font_size)
|
||||
title_block = Block(title, width, title_font, img, max_height, style.TITLE_ALIGN)
|
||||
|
|
@ -239,6 +240,12 @@ def preserve_fields(obj, fields):
|
|||
else:
|
||||
setattr(obj, f, val)
|
||||
|
||||
def normalize(x):
|
||||
if isinstance(x, unicode):
|
||||
import unicodedata
|
||||
x = unicodedata.normalize('NFC', x)
|
||||
return x
|
||||
|
||||
def format_text(mi, prefs):
|
||||
with preserve_fields(mi, 'authors formatted_series_index'):
|
||||
mi.authors = [a for a in mi.authors if a != _('Unknown')]
|
||||
|
|
|
|||
Loading…
Reference in a new issue