From b78ebe5fbc6ff48f2767e403d75d13b932f84f2f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Apr 2025 21:23:03 +0530 Subject: [PATCH] DOCX Input: Add font-weight/style normal declarations, needed by Amazon's renderers --- src/calibre/ebooks/docx/fonts.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/calibre/ebooks/docx/fonts.py b/src/calibre/ebooks/docx/fonts.py index 5c5a44730c..51a05775a5 100644 --- a/src/calibre/ebooks/docx/fonts.py +++ b/src/calibre/ebooks/docx/fonts.py @@ -167,10 +167,15 @@ class Fonts: fname = self.write(name, dest_dir, docx, variant) if fname is not None: d = {'font-family':'"{}"'.format(name.replace('"', '')), 'src': f'url("fonts/{fname}")'} + # The Kindle rendered needs font-weight/style normal for non bold/italic fonts if 'Bold' in variant: d['font-weight'] = 'bold' + else: + d['font-weight'] = 'normal' if 'Italic' in variant: d['font-style'] = 'italic' + else: + d['font-style'] = 'normal' d = [f'{k}: {v}' for k, v in iteritems(d)] d = ';\n\t'.join(d) defs.append(f'@font-face {{\n\t{d}\n}}\n')