Files
OpenVulkano/openVulkanoCpp/Scene/FontAtlasGenerator.hpp
2024-08-06 10:32:55 +03:00

41 lines
1.1 KiB
C++

/*
* 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 <string>
#include <map>
#include "Scene/Texture.hpp"
#include "msdfgen.h"
#include "msdfgen-ext.h"
#include "msdf-atlas-gen/msdf-atlas-gen.h"
namespace OpenVulkano::Scene
{
using namespace msdfgen;
using namespace msdf_atlas;
using namespace OpenVulkano::Scene;
struct GlyphInfo
{
GlyphGeometry geometry;
GlyphBox glyphBox;
Texture texture;
};
class FontAtlasGenerator
{
public:
void GenerateAtlas(const std::string& fontFile, const std::string& outputFile, const Charset& = Charset::ASCII);
std::map<unicode_t, GlyphInfo>& GetAtlasInfo() { return m_symbols; }
private:
std::pair<FreetypeHandle*, FontHandle*> GetHandlers(const std::string& fontFile);
private:
ImmediateAtlasGenerator<float, 1, sdfGenerator, BitmapAtlasStorage<msdfgen::byte, 1>> m_generator;
std::map<unicode_t, GlyphInfo> m_symbols;
std::string m_loadedFont;
};
}