36 lines
1.3 KiB
C++
36 lines
1.3 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 "FontAtlasGeneratorBase.hpp"
|
|
#include "Shelf.hpp"
|
|
|
|
namespace OpenVulkano::Scene
|
|
{
|
|
struct FontPixelSizeConfig
|
|
{
|
|
float size = 24.f;
|
|
float dpi = 72.f;
|
|
bool isPixelSize = true;
|
|
};
|
|
|
|
class BitmapFontAtlasGenerator : public FontAtlasGeneratorBase
|
|
{
|
|
public:
|
|
BitmapFontAtlasGenerator(FontPixelSizeConfig config = FontPixelSizeConfig()) : FontAtlasGeneratorBase(1), m_pixelSizeConfig(config) {}
|
|
void GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset,
|
|
const std::optional<std::string>& pngOutput = std::nullopt) override;
|
|
void GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset,
|
|
const std::optional<std::string>& pngOutput = std::nullopt) override;
|
|
private:
|
|
void Generate(const std::variant<std::string, Array<char>>& source, const std::set<uint32_t>& chset, const std::optional<std::string>& pngOutput);
|
|
std::pair<std::vector<GlyphForPacking>, double> InitGlyphsForPacking(const std::set<uint32_t>& chset, const FtFaceRecPtr& face);
|
|
private:
|
|
FontPixelSizeConfig m_pixelSizeConfig;
|
|
};
|
|
}
|