/* * 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 "IFontAtlasGenerator.hpp" #include "Math/AABB.hpp" #include "FreetypeHelper.hpp" #include #include namespace OpenVulkano::Scene { class FontAtlasGeneratorBase : public IFontAtlasGenerator { public: FontAtlasGeneratorBase(int channelsCount) : m_channelsCount(channelsCount) {} void SaveAtlasMetadataInfo(const std::string& outputFile, bool packIntoSingleFile = true) const override; std::shared_ptr GetAtlasData() const { return m_atlasData; } int GetAtlasChannelsCount() const { return m_channelsCount; } static std::set LoadAllGlyphs(const std::variant>& 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 InitFreetype(const std::variant>& source); protected: int m_channelsCount; std::shared_ptr m_atlasData; }; }