blob: b183818f3b357e0cae051c437b2a715de8a468a1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include "plaintextrenderer.hpp"
#include "renderhelpers.hpp"
#include <QByteArray>
#include <QTextImageFormat>
#include <QTextCursor>
#include <QTextDocument>
#include <memory>
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>();
renderhelpers::setPageMargins(result.get(), style.margin_h, style.margin_v);
QTextCursor cursor { result.get() };
RenderEscapeCodes(input, standard, cursor);
return result;
}
|