forked from qt-creator/qt-creator
ExtensionManager: Use default font for code blocks
Change-Id: I288f13031cd5c35a7e8bc7530c50ccddf5fa1d1f Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -767,6 +767,11 @@ static QTextDocument *highlightText(const QString &code, const QString &language
|
||||
return doc;
|
||||
}
|
||||
|
||||
static QStringList defaultCodeFontFamilies()
|
||||
{
|
||||
return {"Menlo", "Source Code Pro", "Monospace", "Courier"};
|
||||
}
|
||||
|
||||
static void highlightCodeBlock(QTextDocument *document, QTextBlock &block, const QString &language)
|
||||
{
|
||||
int startBlockNumner = block.blockNumber();
|
||||
@@ -813,6 +818,11 @@ static void highlightCodeBlock(QTextDocument *document, QTextBlock &block, const
|
||||
for (auto block = codeDocument->begin(); block != codeDocument->end(); block = block.next()) {
|
||||
if (!first)
|
||||
frameCursor.insertBlock();
|
||||
|
||||
QTextCharFormat charFormat = block.charFormat();
|
||||
charFormat.setFontFamilies(defaultCodeFontFamilies());
|
||||
frameCursor.setCharFormat(charFormat);
|
||||
|
||||
first = false;
|
||||
auto formats = block.layout()->formats();
|
||||
frameCursor.insertText(block.text());
|
||||
|
Reference in New Issue
Block a user