mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
NFC normalize text before rendering in generated cover
This commit is contained in:
parent
70fa77177a
commit
e20672cf45
@ -181,6 +181,7 @@ class Block(object):
|
|||||||
|
|
||||||
def layout_text(prefs, img, title, subtitle, footer, max_height, style):
|
def layout_text(prefs, img, title, subtitle, footer, max_height, style):
|
||||||
width = img.width() - 2 * style.hmargin
|
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 = QFont(prefs.title_font_family or 'Liberation Serif')
|
||||||
title_font.setPixelSize(prefs.title_font_size)
|
title_font.setPixelSize(prefs.title_font_size)
|
||||||
title_block = Block(title, width, title_font, img, max_height, style.TITLE_ALIGN)
|
title_block = Block(title, width, title_font, img, max_height, style.TITLE_ALIGN)
|
||||||
@ -239,6 +240,12 @@ def preserve_fields(obj, fields):
|
|||||||
else:
|
else:
|
||||||
setattr(obj, f, val)
|
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):
|
def format_text(mi, prefs):
|
||||||
with preserve_fields(mi, 'authors formatted_series_index'):
|
with preserve_fields(mi, 'authors formatted_series_index'):
|
||||||
mi.authors = [a for a in mi.authors if a != _('Unknown')]
|
mi.authors = [a for a in mi.authors if a != _('Unknown')]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user