Files
Seele/src/Engine/Asset/FontAsset.cpp
T

41 lines
1.2 KiB
C++
Raw Normal View History

2022-04-13 13:01:35 +02:00
#include "FontAsset.h"
2023-01-29 18:58:59 +01:00
#include "Graphics/Graphics.h"
2023-10-26 18:37:29 +02:00
#include "Graphics/Texture.h"
2022-04-13 13:01:35 +02:00
using namespace Seele;
2024-06-09 12:20:04 +02:00
FontAsset::FontAsset() {}
2022-04-13 13:01:35 +02:00
2024-06-09 12:20:04 +02:00
FontAsset::FontAsset(std::string_view folderPath, std::string_view name) : Asset(folderPath, name) {}
2022-04-13 13:01:35 +02:00
2024-06-09 12:20:04 +02:00
FontAsset::~FontAsset() {}
2022-04-13 13:01:35 +02:00
2025-01-08 19:15:12 +01:00
void FontAsset::save(ArchiveBuffer& buffer) const { Serialization::save(buffer, glyphs); }
2023-02-13 14:56:13 +01:00
2025-01-08 19:15:12 +01:00
void FontAsset::load(ArchiveBuffer& buffer) { Serialization::load(buffer, glyphs); }
2023-11-07 16:55:13 +01:00
2024-06-09 12:20:04 +02:00
void FontAsset::Glyph::save(ArchiveBuffer& buffer) const {
2023-11-07 16:55:13 +01:00
Serialization::save(buffer, size);
Serialization::save(buffer, bearing);
Serialization::save(buffer, advance);
2025-01-08 19:15:12 +01:00
Serialization::save(buffer, textureData);
2023-11-07 16:55:13 +01:00
}
2024-06-09 12:20:04 +02:00
void FontAsset::Glyph::load(ArchiveBuffer& buffer) {
2023-11-07 16:55:13 +01:00
Serialization::load(buffer, size);
Serialization::load(buffer, bearing);
Serialization::load(buffer, advance);
2025-01-08 19:15:12 +01:00
Serialization::load(buffer, textureData);
texture = buffer.getGraphics()->createTexture2D(TextureCreateInfo{
.sourceData =
{
.size = textureData.size(),
.data = textureData.data(),
},
.format = Gfx::SE_FORMAT_R8_UNORM,
.width = size.x,
.height = size.y,
.name = "FontGlyph",
});
2023-11-07 16:55:13 +01:00
}