working version of text rendering

This commit is contained in:
ohyzha
2024-08-02 09:52:26 +03:00
parent 9b58ba5f55
commit e69a553b18
13 changed files with 491 additions and 102 deletions

View File

@@ -0,0 +1,41 @@
/*
* 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;
};
}