-
Notifications
You must be signed in to change notification settings - Fork 4
/
font.h
61 lines (52 loc) · 1.59 KB
/
font.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
#ifndef __FONT_H__
#define __FONT_H__
#include <ft2build.h>
#include FT_FREETYPE_H
#include <hb.h>
#include <hb-ft.h>
//------------------------------------------------------------------------------
class Font
{
unsigned int ID_;
FT_Face ftFont_;
hb_font_t* hbFont_;
float fontSize_;
float contentScale_;
bool bold_;
bool italic_;
float underlinePos_;
float underlineThickness_;
bool initOK_;
public:
Font(FT_Library ftLib, const char* fontFile, float fontSize, float contentScale, bool bold, bool italic);
~Font();
bool Ok() { return initOK_; }
unsigned int getID() const { return ID_; }
FT_Face getFTFont() const { return ftFont_; }
hb_font_t* getHBFont() const { return hbFont_; }
float getSize() const { return fontSize_; }
float getContentScale() const { return contentScale_; }
bool getBold() const { return bold_; }
bool getItalic() const { return italic_; }
bool synthesisBold() const
{
return (bold_ && !(ftFont_->style_flags & FT_STYLE_FLAG_BOLD));
}
bool synthesisItalic() const
{
return (italic_ && !(ftFont_->style_flags & FT_STYLE_FLAG_ITALIC));
}
float getUnderlinePos() const
{
return underlinePos_;
}
float getUnderlineThickness() const
{
return underlineThickness_;
}
private:
void init(FT_Library ftLib, const char* fontFile, float fontSize, float contentScale, bool bold, bool italic);
unsigned int genID();
};
//------------------------------------------------------------------------------
#endif // !__FONT_H__