forked from qt-creator/qt-creator
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 <alessandro.portale@qt.io>
This commit is contained in:
@@ -434,11 +434,15 @@ void MarkdownBrowser::setMarkdown(const QString &markdown)
|
|||||||
cursor.setPosition(fragment.position());
|
cursor.setPosition(fragment.position());
|
||||||
cursor.setPosition(fragment.position() + fragment.length(), QTextCursor::KeepAnchor);
|
cursor.setPosition(fragment.position() + fragment.length(), QTextCursor::KeepAnchor);
|
||||||
if (blockFormat.hasProperty(QTextFormat::HeadingLevel)) {
|
if (blockFormat.hasProperty(QTextFormat::HeadingLevel)) {
|
||||||
// We don't use font size adjustment for headings
|
// Change font size adjustment to resemble the heading font size
|
||||||
charFormat.clearProperty(QTextFormat::FontSizeAdjustment);
|
// (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.setFontCapitalization(headingFont.capitalization());
|
||||||
charFormat.setFontFamilies(headingFont.families());
|
charFormat.setFontFamilies(headingFont.families());
|
||||||
charFormat.setFontPointSize(headingFont.pointSizeF());
|
|
||||||
charFormat.setFontWeight(headingFont.weight());
|
charFormat.setFontWeight(headingFont.weight());
|
||||||
charFormat.setForeground(color(headingTf));
|
charFormat.setForeground(color(headingTf));
|
||||||
} else if (charFormat.isAnchor()) {
|
} else if (charFormat.isAnchor()) {
|
||||||
|
Reference in New Issue
Block a user