From 91c6964f7bc848c592dc56caac3b10293360d2f4 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Wed, 30 Oct 2024 10:00:05 +0100 Subject: [PATCH] Utils: Don't use fixed font sizes for Markdown headings Otherwise the headings won't follow the widgets base font size changes. Change-Id: I8301341570ae46b82d53635bc74f37d418a8feea Reviewed-by: Alessandro Portale --- src/libs/utils/markdownbrowser.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libs/utils/markdownbrowser.cpp b/src/libs/utils/markdownbrowser.cpp index d2b8732f812..b57f4d50a61 100644 --- a/src/libs/utils/markdownbrowser.cpp +++ b/src/libs/utils/markdownbrowser.cpp @@ -434,11 +434,15 @@ void MarkdownBrowser::setMarkdown(const QString &markdown) cursor.setPosition(fragment.position()); cursor.setPosition(fragment.position() + fragment.length(), QTextCursor::KeepAnchor); if (blockFormat.hasProperty(QTextFormat::HeadingLevel)) { - // We don't use font size adjustment for headings - charFormat.clearProperty(QTextFormat::FontSizeAdjustment); + // Change font size adjustment to resemble the heading font size + // (We want the font size to be relative to the default font size, + // otherwise the heading size won't respect the font scale factor) + charFormat.setProperty( + QTextFormat::FontSizeAdjustment, + headingFont.pointSizeF() / document()->defaultFont().pointSizeF()); + charFormat.setFontCapitalization(headingFont.capitalization()); charFormat.setFontFamilies(headingFont.families()); - charFormat.setFontPointSize(headingFont.pointSizeF()); charFormat.setFontWeight(headingFont.weight()); charFormat.setForeground(color(headingTf)); } else if (charFormat.isAnchor()) {