Fix text position

This commit is contained in:
Georg Hagen
2025-01-05 17:15:18 +01:00
parent aca64c57b7
commit 56cb508002
5 changed files with 18 additions and 17 deletions

View File

@@ -7,30 +7,31 @@
#pragma once
#include "IFontAtlasGenerator.hpp"
#include "AtlasData.hpp"
#include "Math/AABB.hpp"
#include "Extensions/FreetypeHelper.hpp"
#include <variant>
#include <set>
namespace OpenVulkano::Scene
{
class FontAtlasGeneratorBase : public IFontAtlasGenerator
{
protected:
int m_channelsCount;
std::shared_ptr<AtlasData> m_atlasData;
public:
FontAtlasGeneratorBase(int channelsCount) : m_channelsCount(channelsCount) {}
FontAtlasGeneratorBase(const int channelsCount) : m_channelsCount(channelsCount) {}
void SaveAtlasMetadataInfo(const std::string& outputFile, bool packIntoSingleFile = true) const override;
std::shared_ptr<AtlasData> GetAtlasData() const { return m_atlasData; }
int GetAtlasChannelsCount() const { return m_channelsCount; }
static std::set<uint32_t> LoadAllGlyphs(const std::variant<std::string, Array<char>>& data);
[[nodiscard]] const std::shared_ptr<AtlasData>& GetAtlasData() const override { return m_atlasData; }
[[nodiscard]] int GetAtlasChannelsCount() const { return m_channelsCount; }
[[nodiscard]] static std::set<uint32_t> LoadAllGlyphs(const std::variant<std::string, Array<char>>& data);
protected:
void SavePng(std::string output) const;
void SetupAtlasData(Math::Vector2ui textureResolution, double lineHeight, FontAtlasType::Type atlasType);
void SetGlyphData(GlyphInfo& info, Math::Vector2d bearing, Math::Vector2d size, const Math::AABB& aabb, double advance);
static std::string GetFreetypeErrorDescription(FT_Error error);
static std::pair<FtLibraryRecPtr, FtFaceRecPtr> InitFreetype(const std::variant<std::string, Array<char>>& source);
protected:
int m_channelsCount;
std::shared_ptr<AtlasData> m_atlasData;
[[nodiscard]] static std::string GetFreetypeErrorDescription(FT_Error error);
[[nodiscard]] static std::pair<FtLibraryRecPtr, FtFaceRecPtr> InitFreetype(const std::variant<std::string, Array<char>>& source);
};
}