Move FontAtlasType into its own file

This commit is contained in:
Georg Hagen
2025-01-10 18:31:34 +01:00
parent f58064d724
commit c2152e6b3c
2 changed files with 43 additions and 30 deletions

View File

@@ -10,6 +10,7 @@
#include "Math/Math.hpp" #include "Math/Math.hpp"
#include "Image/Image.hpp" #include "Image/Image.hpp"
#include "Scene/Texture.hpp" #include "Scene/Texture.hpp"
#include "Scene/Text/FontAtlasType.hpp"
#include <string_view> #include <string_view>
#include <map> #include <map>
#include <magic_enum.hpp> #include <magic_enum.hpp>
@@ -25,36 +26,6 @@ namespace OpenVulkano::Scene
double advance = 0; double advance = 0;
}; };
class FontAtlasType
{
public:
enum Type : int16_t
{
SDF = 0,
MSDF,
BITMAP,
UNKNOWN
};
static constexpr std::string_view DEFAULT_FG_SHADERS[] = { "Shader/sdfText", "Shader/msdfText", "Shader/text" };
constexpr FontAtlasType(Type type) : m_type(type) {}
[[nodiscard]] constexpr Type GetType() const { return m_type; }
[[nodiscard]] constexpr auto GetName() const { return magic_enum::enum_name(m_type); }
[[nodiscard]] constexpr const std::string_view& GetDefaultFragmentShader() const
{
return DEFAULT_FG_SHADERS[static_cast<int>(m_type)];
}
[[nodiscard]] constexpr operator Type() const { return m_type; }
private:
Type m_type;
};
struct AtlasMetadata struct AtlasMetadata
{ {
// vertical difference between baselines // vertical difference between baselines

View File

@@ -0,0 +1,42 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <magic_enum.hpp>
namespace OpenVulkano::Scene
{
class FontAtlasType
{
public:
enum Type : int16_t
{
SDF = 0,
MSDF,
BITMAP,
UNKNOWN
};
static constexpr std::string_view DEFAULT_FG_SHADERS[] = { "Shader/sdfText", "Shader/msdfText", "Shader/text" };
constexpr FontAtlasType(Type type) : m_type(type) {}
[[nodiscard]] constexpr Type GetType() const { return m_type; }
[[nodiscard]] constexpr auto GetName() const { return magic_enum::enum_name(m_type); }
[[nodiscard]] constexpr const std::string_view& GetDefaultFragmentShader() const
{
return DEFAULT_FG_SHADERS[static_cast<int>(m_type)];
}
[[nodiscard]] constexpr operator Type() const { return m_type; }
private:
Type m_type;
};
}