From a548dcb2c73537032a417cc304b5a2fc2016d1f7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 14 Sep 2022 11:12:28 +0530 Subject: [PATCH] Better fix for font-weight: 0 Qt bug --- src/calibre/gui2/comments_editor.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py index ac7dcc3d9b..f1617be838 100644 --- a/src/calibre/gui2/comments_editor.py +++ b/src/calibre/gui2/comments_editor.py @@ -537,7 +537,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{ cf = QTextCharFormat() bcf = c.blockCharFormat() lvl = self.level_for_block_type(name) - wt = QFont.Weight.Bold if lvl else None + wt = QFont.Weight.Bold if lvl else QFont.Weight.Normal adjust = (0, 3, 2, 1, 0, -1, -1)[lvl] pos = None if not c.hasSelection(): @@ -562,12 +562,10 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{ bf.setLeftMargin(hmargin), bf.setRightMargin(hmargin) bf.setTopMargin(tmargin), bf.setBottomMargin(bmargin) bf.setHeadingLevel(lvl) - if adjust: - bcf.setProperty(QTextFormat.Property.FontSizeAdjustment, adjust) - cf.setProperty(QTextFormat.Property.FontSizeAdjustment, adjust) - if wt: - bcf.setProperty(QTextFormat.Property.FontWeight, wt) - cf.setProperty(QTextFormat.Property.FontWeight, wt) + bcf.setProperty(QTextFormat.Property.FontSizeAdjustment, adjust) + cf.setProperty(QTextFormat.Property.FontSizeAdjustment, adjust) + bcf.setFontWeight(wt) + cf.setFontWeight(wt) c.setBlockCharFormat(bcf) c.mergeCharFormat(cf) c.mergeBlockFormat(bf)