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
FontContext.cpp
Go to the documentation of this file.
1
7
8
#include "galaxy/core/ServiceLocator.hpp"
9
#include "
galaxy/core/Window.hpp
"
10
#include "galaxy/error/Log.hpp"
11
12
#include "
FontContext.hpp
"
13
14
namespace
galaxy
15
{
16
namespace
graphics
17
{
18
FontContext::FontContext
()
19
: m_context {nullptr}
20
{
21
m_context
= msdfgl_create_context(
nullptr
);
22
if
(!
m_context
)
23
{
24
GALAXY_LOG
(
GALAXY_FATAL
,
"Failed to create font context."
);
25
}
26
else
27
{
28
msdfgl_set_missing_glyph_callback(
m_context
, msdfgl_generate_glyph,
nullptr
);
29
30
auto
& w = core::ServiceLocator<core::Window>::ref();
31
32
const
auto
scale = w.get_content_scale();
33
set_dpi
(scale.x, scale.y);
34
}
35
}
36
37
FontContext::~FontContext
()
38
{
39
if
(
m_context
!=
nullptr
)
40
{
41
msdfgl_destroy_context(
m_context
);
42
}
43
}
44
45
void
FontContext::set_dpi
(
const
float
x,
const
float
y)
const
46
{
47
msdfgl_set_dpi(
m_context
, x, y);
48
}
49
50
msdfgl_context_t
FontContext::context
()
51
{
52
return
m_context
;
53
}
54
}
// namespace graphics
55
}
// namespace galaxy
FontContext.hpp
GALAXY_LOG
#define GALAXY_LOG(level, msg,...)
Definition
Log.hpp:28
GALAXY_FATAL
#define GALAXY_FATAL
Definition
Log.hpp:25
galaxy::graphics::FontContext::m_context
msdfgl_context_t m_context
Library context object.
Definition
FontContext.hpp:79
galaxy::graphics::FontContext::context
msdfgl_context_t context()
Get font context object.
Definition
FontContext.cpp:50
galaxy::graphics::FontContext::set_dpi
void set_dpi(const float x, const float y) const
Set font DPI.
Definition
FontContext.cpp:45
galaxy::graphics::FontContext::~FontContext
~FontContext()
Destructor.
Definition
FontContext.cpp:37
galaxy::graphics::FontContext::FontContext
FontContext()
Constructor.
Definition
FontContext.cpp:18
Window.hpp
galaxy
Animated.cpp galaxy.
Definition
Animated.cpp:16
galaxy
src
galaxy
graphics
text
FontContext.cpp
Generated on Fri Sep 12 2025 07:29:48 for galaxy by
1.12.0