neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
font.hpp
Go to the documentation of this file.
1
// font.hpp
2
/*
3
neogfx C++ App/Game Engine
4
Copyright (c) 2018, 2020 Leigh Johnston. All Rights Reserved.
5
6
This program is free software: you can redistribute it and / or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <
neogfx/neogfx.hpp
>
23
#include <
neolib/core/uuid.hpp
>
24
#include <
neolib/core/string.hpp
>
25
#include <
neogfx/game/ecs_ids.hpp
>
26
#include <
neogfx/game/i_ecs.hpp
>
27
#include <
neogfx/game/i_component_data.hpp
>
28
#include <
neogfx/gfx/text/font_manager.hpp
>
29
30
namespace
neogfx::game
31
{
32
struct
font
33
{
34
neolib::small_cookie_ref_ptr
id
;
35
string
familyName
;
36
string
styleName
;
37
scalar
pointSize
;
38
bool
underline
;
39
40
struct
meta
:
i_component_data::meta
41
{
42
static
const
neolib::uuid
&
id
()
43
{
44
static
const
neolib::uuid
sId = { 0x13edb5d4, 0x9fae, 0x4dc1, 0xb9e4, { 0x15, 0x49, 0x8b, 0xf, 0xff, 0xe } };
45
return
sId;
46
}
47
static
const
i_string
&
name
()
48
{
49
static
const
string
sName =
"Font"
;
50
return
sName;
51
}
52
static
uint32_t
field_count
()
53
{
54
return
5;
55
}
56
static
component_data_field_type
field_type
(uint32_t aFieldIndex)
57
{
58
switch
(aFieldIndex)
59
{
60
case
0:
61
return
component_data_field_type::SmallId;
62
case
1:
63
case
2:
64
return
component_data_field_type::String;
65
case
3:
66
return
component_data_field_type::Scalar;
67
case
4:
68
return
component_data_field_type::Bool;
69
default
:
70
throw
invalid_field_index
();
71
}
72
}
73
static
const
i_string
&
field_name
(uint32_t aFieldIndex)
74
{
75
static
const
string
sFieldNames[] =
76
{
77
"Id"
,
78
"Family Name"
,
79
"Style Name"
,
80
"Point Size"
,
81
"Underline"
82
};
83
return
sFieldNames[aFieldIndex];
84
}
85
static
constexpr
bool
has_updater
=
true
;
86
static
void
update
(
font
& aData,
i_ecs
&,
entity_id
)
87
{
88
neogfx::font_info fontInfo{ aData.
familyName
, aData.
styleName
, aData.
pointSize
};
89
fontInfo.set_underline(aData.
underline
);
90
aData.
id
=
neolib::small_cookie_ref_ptr
{ service<i_font_manager>(), neogfx::font{ fontInfo }.id() };
91
}
92
};
93
};
94
}
neolib::ecs::i_ecs
Definition
i_ecs.hpp:85
neolib::i_string
Definition
i_string.hpp:49
font_manager.hpp
neogfx::game
Definition
aabb_octree.hpp:31
neolib::ecs::component_data_field_type
component_data_field_type
Definition
i_component_data.hpp:52
neolib::ecs::entity_id
id_t entity_id
Definition
ecs_ids.hpp:51
neolib::math::scalar
double scalar
Definition
numerical.hpp:63
neolib::small_cookie_ref_ptr
basic_cookie_ref_ptr< small_cookie > small_cookie_ref_ptr
Definition
jar.hpp:733
ecs_ids.hpp
i_component_data.hpp
i_ecs.hpp
neogfx.hpp
string.hpp
neogfx::game::font::meta
Definition
font.hpp:41
neogfx::game::font::meta::update
static void update(font &aData, i_ecs &, entity_id)
Definition
font.hpp:86
neogfx::game::font::meta::field_type
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition
font.hpp:56
neogfx::game::font::meta::field_count
static uint32_t field_count()
Definition
font.hpp:52
neogfx::game::font::meta::field_name
static const i_string & field_name(uint32_t aFieldIndex)
Definition
font.hpp:73
neogfx::game::font::meta::id
static const neolib::uuid & id()
Definition
font.hpp:42
neogfx::game::font::meta::has_updater
static constexpr bool has_updater
Definition
font.hpp:85
neogfx::game::font::meta::name
static const i_string & name()
Definition
font.hpp:47
neogfx::game::font
Definition
font.hpp:33
neogfx::game::font::id
neolib::small_cookie_ref_ptr id
Definition
font.hpp:34
neogfx::game::font::pointSize
scalar pointSize
Definition
font.hpp:37
neogfx::game::font::familyName
string familyName
Definition
font.hpp:35
neogfx::game::font::underline
bool underline
Definition
font.hpp:38
neogfx::game::font::styleName
string styleName
Definition
font.hpp:36
neolib::ecs::i_component_data::meta::invalid_field_index
Definition
i_component_data.hpp:134
neolib::ecs::i_component_data::meta
Definition
i_component_data.hpp:133
neolib::uuid
Definition
uuid.hpp:51
uuid.hpp
include
neogfx
game
font.hpp
Generated by
1.9.8