-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtextimagecreator.h
More file actions
59 lines (49 loc) · 1.17 KB
/
textimagecreator.h
File metadata and controls
59 lines (49 loc) · 1.17 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef TEXTIMAGECREATOR_H
#define TEXTIMAGECREATOR_H
#include <QJsonObject>
#include <QColor>
#include <QPainter>
#include <QPen>
#include <QFont>
#include <QPicture>
#include <QVector>
#include <QRect>
#include <QTextDocument>
class TextImageCreator
{
public:
TextImageCreator();
~TextImageCreator();
void inputRules(const QJsonObject & rule);
void process(const QString & text, const QString & filePath);
private:
void computeMaxSizes();
void findProperFont(const QString & text);
int findMaxWidthString(const QStringList &strList, QString &maxLenStr);
int measureTextWidth(const QString & text);
int m_width;
int m_height;
int m_validWidth;
int m_validHeight;
int m_margin;
QColor m_fontColor;
QColor m_bgColor;
QPixmap m_bgImg;
QString m_lineBreak;
int m_maxCnSize;
int m_minCnSize;
int m_maxEnSize;
int m_minEnSize;
QFont m_font;
int m_minSize;
int m_maxSize;
int m_fontSize;
QPainter *m_painter;
QPen m_pen;
QImage *m_picture;
QTextDocument m_textDoc;
QVector<int> m_cnSizes;
QVector<int> m_enSizes;
QRect m_validRect;
};
#endif // TEXTIMAGECREATOR_H