-
Notifications
You must be signed in to change notification settings - Fork 0
/
layoutengine.h
54 lines (43 loc) · 1.27 KB
/
layoutengine.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
#ifndef LAYOUTENGINE_H
#define LAYOUTENGINE_H
#include <raqm.h>
#include <QString>
#include <QGlyphRun>
#include <QRawFont>
struct PropertyHolder{
QGlyphRun glyph;
QRawFont font;
bool operator==(const PropertyHolder p){
return glyph == p.glyph && p.font == font;
}
};
class LayoutEngine
{
public:
LayoutEngine() = default;
~LayoutEngine();
inline void setFontFace(QString font) { m_font = font; }
inline void setText(QString text) { m_text = text; }
inline void setFontSize(int size) { m_fontSize = size; }
inline void setLetterSpacing(qreal spacing) { m_letterSpacing = spacing; }
inline void setWordSpacing(qreal spacing) { m_wordSpacing = spacing; }
inline raqm_direction_t direction() { return m_direction; }
inline int fontSize() { return m_fontSize; }
inline void setDirection(bool vertical){
if(vertical)
m_direction = RAQM_DIRECTION_TTB;
else
m_direction = RAQM_DIRECTION_DEFAULT;
}
PropertyHolder calculate();
private:
QString m_font, m_text;
raqm_direction_t m_direction;
const char *m_language = "en";
raqm_t *m_rq;
FT_Face m_face;
FT_Library m_library;
int m_fontSize;
qreal m_letterSpacing, m_wordSpacing;
};
#endif // LAYOUTENGINE_H