galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Font.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_GRAPHICS_TEXT_FONT_HPP_
9#define GALAXY_GRAPHICS_TEXT_FONT_HPP_
10
11#include <string>
12
13#include <glm/vec2.hpp>
14
16
17namespace galaxy
18{
19 namespace graphics
20 {
24 class Font final
25 {
26 public:
30 Font();
31
35 Font(Font&&);
36
41
45 ~Font();
46
54 [[nodiscard]]
55 bool load(const std::string& file);
56
65 [[nodiscard]]
66 bool load(unsigned char* buffer, const unsigned int size);
67
73 void build();
74
82 [[nodiscard]]
83 float vertical_advance(const float size) const;
84
95 [[nodiscard]]
96 glm::vec2 get_text_size(const std::string& text, const float size);
97
103 [[nodiscard]]
104 msdfgl_font_t handle();
105
106 private:
110 msdfgl_font_t m_font;
111
117 FT_Face m_face;
118 };
119 } // namespace graphics
120} // namespace galaxy
121
122#endif
A font is a MSDF atlas of glyphs.
Definition Font.hpp:25
Font & operator=(Font &&)
Move assignment operator.
Definition Font.cpp:38
msdfgl_font_t handle()
Get handle to internal font object.
Definition Font.cpp:170
msdfgl_font_t m_font
Font object.
Definition Font.hpp:110
Font()
Constructor.
Definition Font.cpp:18
void build()
Build the font atlas.
Definition Font.cpp:107
bool load(const std::string &file)
Loads the font and sets up characters.
Definition Font.cpp:67
FT_Face m_face
Freetype face.
Definition Font.hpp:117
~Font()
Destructor.
Definition Font.cpp:57
glm::vec2 get_text_size(const std::string &text, const float size)
Query text size with font.
Definition Font.cpp:130
float vertical_advance(const float size) const
Get vertical advance for drawing multiline text.
Definition Font.cpp:125
Animated.cpp galaxy.
Definition Animated.cpp:16