forked from Aloshi/EmulationStation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFont.h
More file actions
67 lines (49 loc) · 1.44 KB
/
Font.h
File metadata and controls
67 lines (49 loc) · 1.44 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
60
61
62
63
64
65
66
67
#ifndef _FONT_H_
#define _FONT_H_
#include <string>
#include "platform.h"
#include GLHEADER
#include <ft2build.h>
#include FT_FREETYPE_H
//A TrueType Font renderer that uses FreeType and OpenGL.
//The library is automatically initialized when it's needed.
class Font
{
public:
static void initLibrary();
Font(std::string path, int size);
~Font();
FT_Face face;
//contains sizing information for every glyph.
struct charPosData {
int texX;
int texY;
int texW;
int texH;
float advX;
float advY;
float bearingY;
};
charPosData charData[128];
GLuint textureID;
void drawText(std::string text, int startx, int starty, int color); //Render some text using this font.
void sizeText(std::string text, int* w, int* h); //Sets the width and height of a given string to given pointers. Skipped if pointer is NULL.
int getHeight();
void init();
void deinit();
int getSize();
static std::string getDefaultPath();
private:
static int getDpiX();
static int getDpiY();
static FT_Library sLibrary;
static bool libraryInitialized;
void buildAtlas(); //Builds a "texture atlas," one big OpenGL texture with glyphs 32 to 128.
int textureWidth; //OpenGL texture width
int textureHeight; //OpenGL texture height
int mMaxGlyphHeight;
float fontScale; //!<Font scale factor. It is > 1.0 if the font would be to big for the texture
std::string mPath;
int mSize;
};
#endif