Font builder
This commit is contained in:
52
src/runtime/FontAtlasBuilder.h
Normal file
52
src/runtime/FontAtlasBuilder.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include "ShaderTypes.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace RenderCadenceCompositor
|
||||
{
|
||||
struct FontAtlasBuildConfig
|
||||
{
|
||||
std::filesystem::path repoRoot;
|
||||
std::filesystem::path cacheRoot;
|
||||
double sizePixelsPerEm = 64.0;
|
||||
double pixelRange = 4.0;
|
||||
std::string atlasType = "mtsdf";
|
||||
};
|
||||
|
||||
struct FontAtlasBuildOutput
|
||||
{
|
||||
std::string fontId;
|
||||
std::filesystem::path imagePath;
|
||||
std::filesystem::path jsonPath;
|
||||
};
|
||||
|
||||
class FontAtlasBuilder
|
||||
{
|
||||
public:
|
||||
explicit FontAtlasBuilder(FontAtlasBuildConfig config);
|
||||
|
||||
bool BuildPackageFontAtlases(
|
||||
const ShaderPackage& shaderPackage,
|
||||
std::vector<FontAtlasBuildOutput>& outputs,
|
||||
std::string& error) const;
|
||||
|
||||
bool BuildFontAtlas(
|
||||
const ShaderPackage& shaderPackage,
|
||||
const ShaderFontAsset& fontAsset,
|
||||
FontAtlasBuildOutput& output,
|
||||
std::string& error) const;
|
||||
|
||||
static bool FindMsdfAtlasGenExecutable(const std::filesystem::path& repoRoot, std::filesystem::path& executablePath);
|
||||
|
||||
private:
|
||||
std::filesystem::path PackageCacheDirectory(const ShaderPackage& shaderPackage) const;
|
||||
static std::string SanitizePathToken(const std::string& value);
|
||||
static bool RunProcess(const std::string& commandLine, const std::filesystem::path& workingDirectory, std::string& error);
|
||||
|
||||
FontAtlasBuildConfig mConfig;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user