SGCT master (487fac4)
Simple Graphics Cluster Toolkit
Loading...
Searching...
No Matches
font.h
Go to the documentation of this file.
1/*****************************************************************************************
2 * SGCT *
3 * Simple Graphics Cluster Toolkit *
4 * *
5 * Copyright (c) 2012-2026 *
6 * For conditions of distribution and use, see copyright notice in LICENSE.md *
7 ****************************************************************************************/
8
9#ifndef __SGCT__FONT__H__
10#define __SGCT__FONT__H__
11
12#ifdef SGCT_HAS_TEXT
13
14#include <sgct/sgctexports.h>
15
16#include <sgct/math.h>
17#include <unordered_map>
18
19typedef struct FT_LibraryRec_* FT_Library;
20typedef struct FT_GlyphRec_* FT_Glyph;
21typedef struct FT_FaceRec_* FT_Face;
22typedef signed long FT_Fixed;
23
24namespace sgct::text {
25
31class SGCT_EXPORT Font {
32public:
33 struct FontFaceData {
34 unsigned int texId = 0;
35 float distToNextChar = 0.f;
36 vec2 pos = vec2{ 0.f, 0.f };
37 vec2 size = vec2{ 0.f, 0.f };
38 FT_Glyph glyph = nullptr;
39 };
40
48 Font(FT_Library lib, FT_Face face, unsigned int height);
49
53 ~Font();
54
58 const Font::FontFaceData& fontFaceData(char c);
59
63 unsigned int vao() const;
64
68 float height() const;
69
75 void setStrokeSize(int size);
76
77private:
78 void createCharacter(char c);
79
80 const FT_Library _library;
81 const FT_Face _face;
82 FT_Fixed _strokeSize = 1;
83 const float _height;
84 std::unordered_map<char, FontFaceData> _fontFaceData;
85 unsigned int _vao = 0;
86 unsigned int _vbo = 0;
87};
88
89} // namespace sgct
90
91#endif // SGCT_HAS_TEXT
92#endif // __SGCT__FONT__H__
Definition freetype.h:22