2022-04-13 13:01:35 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include "Asset.h"
|
2023-02-13 14:56:13 +01:00
|
|
|
#include "Containers/Map.h"
|
|
|
|
|
#include "Math/Math.h"
|
2022-04-13 13:01:35 +02:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
namespace Seele {
|
2022-04-13 13:01:35 +02:00
|
|
|
DECLARE_NAME_REF(Gfx, Texture2D)
|
2024-06-09 12:20:04 +02:00
|
|
|
class FontAsset : public Asset {
|
|
|
|
|
public:
|
2023-02-13 14:56:13 +01:00
|
|
|
static constexpr uint64 IDENTIFIER = 0x10;
|
2022-04-13 13:01:35 +02:00
|
|
|
FontAsset();
|
2023-02-13 14:56:13 +01:00
|
|
|
FontAsset(std::string_view folderPath, std::string_view name);
|
2022-04-13 13:01:35 +02:00
|
|
|
virtual ~FontAsset();
|
2023-02-13 14:56:13 +01:00
|
|
|
virtual void save(ArchiveBuffer& buffer) const override;
|
|
|
|
|
virtual void load(ArchiveBuffer& buffer) override;
|
2022-04-15 11:19:30 +02:00
|
|
|
|
2024-06-09 12:20:04 +02:00
|
|
|
struct Glyph {
|
2023-11-07 16:55:13 +01:00
|
|
|
uint32 textureIndex;
|
2023-01-21 18:43:21 +01:00
|
|
|
IVector2 size;
|
|
|
|
|
IVector2 bearing;
|
2022-04-15 11:19:30 +02:00
|
|
|
uint32 advance;
|
2023-11-07 16:55:13 +01:00
|
|
|
void save(ArchiveBuffer& buffer) const;
|
|
|
|
|
void load(ArchiveBuffer& buffer);
|
2022-04-13 13:01:35 +02:00
|
|
|
};
|
2023-02-01 22:13:04 +01:00
|
|
|
const Map<uint32, Glyph> getGlyphData() const { return glyphs; }
|
2023-11-07 16:55:13 +01:00
|
|
|
Gfx::PTexture2D getTexture(uint32 index) { return usedTextures[index]; }
|
|
|
|
|
void setUsedTextures(Array<Gfx::OTexture2D> _usedTextures);
|
2024-06-09 12:20:04 +02:00
|
|
|
|
|
|
|
|
private:
|
2023-11-05 10:36:01 +01:00
|
|
|
Array<Gfx::OTexture2D> usedTextures;
|
2023-02-01 22:13:04 +01:00
|
|
|
Map<uint32, Glyph> glyphs;
|
2023-01-29 18:58:59 +01:00
|
|
|
friend class FontLoader;
|
2022-04-13 13:01:35 +02:00
|
|
|
};
|
|
|
|
|
DECLARE_REF(FontAsset)
|
|
|
|
|
} // namespace Seele
|