-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtext.cpp
45 lines (35 loc) · 1.16 KB
/
text.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <cppunit/TestCase.h>
#include "Texture/Textures.h"
#include "Procedural/ProcTextures.h"
#include "System/Config.h"
#include <QPainter>
#include <QApplication>
class TextureTest: public CppUnit::TestCase {
public:
TextureTest(std::string name) :
CppUnit::TestCase(name) {
}
void runTest() {
QSize screenSize = QSize(480,600);
QImage image = QImage(screenSize, QImage::Format_ARGB32);
QRectF drawBox = QRectF(50,200,screenSize.width()-100, screenSize.height()-100);
QPainter fontPainter(&image);
//draw font
fontPainter.setRenderHint(QPainter::Antialiasing, true);
fontPainter.setRenderHint(QPainter::TextAntialiasing, true);
fontPainter.setRenderHint(QPainter::SmoothPixmapTransform, true);
fontPainter.setFont(QFont("Ubuntu", 50));
fontPainter.setLayoutDirection(Qt::RightToLeft);
fontPainter.setPen(Qt::black);
string text = "foooBUNTU";
fontPainter.drawText(drawBox, Qt::AlignLeft, QString::fromStdString(text));
fontPainter.end();
image.save("texttest.png");
}
};
//int main() {
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
TextureTest foo2("bar");
foo2.runTest();
}