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>
26#include <neogfx/game/i_ecs.hpp>
29
30namespace neogfx::game
31{
32 struct font
33 {
35 string familyName;
36 string styleName;
39
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}
id_t entity_id
Definition ecs_ids.hpp:51
double scalar
Definition numerical.hpp:63
basic_cookie_ref_ptr< small_cookie > small_cookie_ref_ptr
Definition jar.hpp:733
static void update(font &aData, i_ecs &, entity_id)
Definition font.hpp:86
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition font.hpp:56
static uint32_t field_count()
Definition font.hpp:52
static const i_string & field_name(uint32_t aFieldIndex)
Definition font.hpp:73
static const neolib::uuid & id()
Definition font.hpp:42
static constexpr bool has_updater
Definition font.hpp:85
static const i_string & name()
Definition font.hpp:47
neolib::small_cookie_ref_ptr id
Definition font.hpp:34
scalar pointSize
Definition font.hpp:37
string familyName
Definition font.hpp:35
string styleName
Definition font.hpp:36