aboutsummaryrefslogtreecommitdiff
path: root/src/plaintextrenderer.cpp
blob: 37801a434e2fdf64128839ca226eb2bc471e7e05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "plaintextrenderer.hpp"

#include <QTextImageFormat>
#include <QTextCursor>

std::unique_ptr<QTextDocument> PlainTextRenderer::render(const QByteArray &input, const DocumentStyle &style)
{
    QTextCharFormat standard;
    standard.setFont(style.preformatted_font);
    standard.setForeground(style.preformatted_color);

    std::unique_ptr<QTextDocument> result = std::make_unique<QTextDocument>();
    result->setDocumentMargin(style.margin);

    QTextCursor cursor { result.get() };
    cursor.insertText(QString::fromUtf8(input), standard);

    return result;
}