Use default QTD font size for mono font when importing markdown

QFontDatabase::systemFont(FixedFont) determines the font for inline code and
code blocks in a markdown document.  Now we change the size of that font to the
same size as QTextDocument::defaultFont() so that the user has the ability to
customize the font size in each document instead of only system-wide.

Change-Id: Ief7367336f7613e88695dbb08bcb7e9f50db8961
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Eike Ziller 2019-11-08 14:02:01 +01:00 committed by Shawn Rutledge
parent 8693c07a80
commit 3641606008

View File

@ -160,6 +160,10 @@ void QTextMarkdownImporter::import(QTextDocument *doc, const QString &markdown)
m_paragraphMargin = m_doc->defaultFont().pointSize() * 2 / 3;
m_cursor = new QTextCursor(doc);
doc->clear();
if (doc->defaultFont().pointSize() != -1)
m_monoFont.setPointSize(doc->defaultFont().pointSize());
else
m_monoFont.setPixelSize(doc->defaultFont().pixelSize());
qCDebug(lcMD) << "default font" << doc->defaultFont() << "mono font" << m_monoFont;
QByteArray md = markdown.toUtf8();
md_parse(md.constData(), MD_SIZE(md.size()), &callbacks, this);