From fd4081aed8682bbadff804b4838cdff3763021fd Mon Sep 17 00:00:00 2001 From: matthew-gill Date: Wed, 5 Jul 2023 14:29:30 +0100 Subject: [PATCH] Update codeblock font --- gpt4all-chat/responsetext.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gpt4all-chat/responsetext.cpp b/gpt4all-chat/responsetext.cpp index f23d4898..0dce1f60 100644 --- a/gpt4all-chat/responsetext.cpp +++ b/gpt4all-chat/responsetext.cpp @@ -616,7 +616,17 @@ void ResponseText::handleCodeBlocks() QTextCursor codeCellCursor = codeCell.firstCursorPosition(); QTextTable *codeTable = codeCellCursor.insertTable(1, 1, codeBlockTableFormat); QTextTableCell code = codeTable->cellAt(0, 0); + + QTextCharFormat codeBlockCharFormat; + QFont monospaceFont("Courier"); + if (monospaceFont.family() != "Courier") { + monospaceFont.setFamily("Monospace"); // Fallback if Courier isn't available + } + QTextCursor codeCursor = code.firstCursorPosition(); + codeBlockCharFormat.setFont(monospaceFont); // Update the font for the codeblock + codeCursor.setCharFormat(codeBlockCharFormat); + if (!codeLanguage.isEmpty()) { codeCursor.block().setUserState(stringToLanguage(codeLanguage)); for (const QString &line : lines) {