-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlowlevel_textrender.h
111 lines (105 loc) · 3.17 KB
/
lowlevel_textrender.h
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/***************************************************************************
* Copyright (C) 2018-2019 by Chernov A.A. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef LOWLEVEL_TEXTRENDER_H
#define LOWLEVEL_TEXTRENDER_H
#include <QtWidgets/QWidget>
class QPaintEvent;
class QImage;
class GLowLevelTextRenderPrivate;
class GLowLevelTextRender: public QWidget
{
Q_OBJECT
public:
enum AntialiasingMode
{
AntialiasNone,
AntialiasGray,
AntialiasLCD_RGB,
AntialiasLCD_BGR,
AntialiasLCD_PenTile,
AntialiasLCD_V_RGB,
AntialiasLCD_V_BGR,
AntialiasLCD_V_PenTile
};
enum HintingMode
{
HintingNone,
HintingByteCode,
HintingAuto
};
public:
explicit GLowLevelTextRender(QWidget *parent = nullptr);
virtual ~GLowLevelTextRender();
bool setFontFace(const QString& fileName);
bool setFontPointSize(float size, int dpi = 96);
bool setFontPixelSize(int size);
AntialiasingMode antialiasingMode() const
{
return m_antialiasingMode;
}
void setAntialiasingMode(AntialiasingMode mode);
HintingMode hintingMode() const
{
return m_hintingMode;
}
void setHintingMode(HintingMode hinting);
bool isKerning() const
{
return m_useKerning;
}
void setKerning(bool kerning);
bool ligaturesAllowed() const
{
return m_allowLigatures;
}
void setAllowLigatures(bool ligatures);
QColor textColor() const
{
return m_textColor;
}
void setTextColor(const QColor& textColor);
double gammaCorrection() const
{
return m_gamma;
}
void setGammaCorrection(double gamma);
QColor backgroundColor() const
{
return m_backgroundColor;
}
void setBackgroundColor(const QColor& color);
QStringList getSupportedLanguages();
protected:
virtual void paintEvent(QPaintEvent *event);
public slots:
bool renderText(const QString& text);
bool renderText();
private:
GLowLevelTextRenderPrivate* m_d;
float m_fontSize;
QString m_text;
QColor m_textColor;
QColor m_backgroundColor;
AntialiasingMode m_antialiasingMode;
HintingMode m_hintingMode;
bool m_useKerning;
bool m_allowLigatures;
double m_gamma;
QImage* m_offscreen;
};
#endif // LOWLEVEL_TEXTRENDER_H