2023-12-17 03:29:08 -08:00
|
|
|
#pragma once
|
|
|
|
|
2024-01-14 09:38:57 -08:00
|
|
|
#include "ehs/EHS.h"
|
|
|
|
#include "ehs/Array.h"
|
2023-12-17 03:29:08 -08:00
|
|
|
|
|
|
|
#include "Glyph.h"
|
2024-01-14 09:38:57 -08:00
|
|
|
#include "ehs/Anchor.h"
|
|
|
|
#include "ehs/io/img/Img.h"
|
|
|
|
#include "ehs/io/model/Mesh.h"
|
2023-12-17 03:29:08 -08:00
|
|
|
|
2023-12-17 15:56:13 -08:00
|
|
|
namespace ehs
|
2023-12-17 03:29:08 -08:00
|
|
|
{
|
2024-01-23 17:26:27 -08:00
|
|
|
class FontAtlas : public BaseObj
|
2023-12-17 03:29:08 -08:00
|
|
|
{
|
|
|
|
private:
|
2024-01-23 17:26:27 -08:00
|
|
|
UInt_64 hashId;
|
|
|
|
Str_8 id;
|
2023-12-17 03:29:08 -08:00
|
|
|
UInt_64 glyphScale;
|
|
|
|
Array<Glyph> glyphs;
|
2024-01-23 17:26:27 -08:00
|
|
|
Vec2_u64 resolution;
|
|
|
|
UInt_64 size;
|
|
|
|
Byte* atlas;
|
2023-12-17 03:29:08 -08:00
|
|
|
|
|
|
|
public:
|
2024-01-23 17:26:27 -08:00
|
|
|
~FontAtlas() override;
|
|
|
|
|
2023-12-17 03:29:08 -08:00
|
|
|
FontAtlas();
|
|
|
|
|
|
|
|
FontAtlas(const Str_8& filePath);
|
|
|
|
|
|
|
|
FontAtlas(FontAtlas&& fa) noexcept;
|
|
|
|
|
|
|
|
FontAtlas(const FontAtlas& fa);
|
|
|
|
|
|
|
|
FontAtlas& operator=(FontAtlas&& fa) noexcept;
|
|
|
|
|
|
|
|
FontAtlas& operator=(const FontAtlas& fa);
|
|
|
|
|
2024-01-23 17:26:27 -08:00
|
|
|
operator Byte*() const;
|
|
|
|
|
|
|
|
void Release();
|
|
|
|
|
|
|
|
UInt_64 GetHashId() const;
|
|
|
|
|
|
|
|
Str_8 GetId() const;
|
|
|
|
|
2023-12-17 03:29:08 -08:00
|
|
|
UInt_64 GetGlyphScale() const;
|
|
|
|
|
2024-01-24 17:38:34 -08:00
|
|
|
const Array<Glyph>& GetGlyphs() const;
|
|
|
|
|
2023-12-18 02:13:20 -08:00
|
|
|
Glyph GetGlyph(Char_32 code) const;
|
2023-12-17 03:29:08 -08:00
|
|
|
|
2024-01-23 17:26:27 -08:00
|
|
|
Vec2_u64 GetResolution() const;
|
|
|
|
|
|
|
|
UInt_64 GetSize() const;
|
|
|
|
|
|
|
|
bool IsValid() const;
|
|
|
|
|
2023-12-17 03:29:08 -08:00
|
|
|
Vec2_f CalculateSize(const Str_8& text) const;
|
|
|
|
|
|
|
|
float CalculateWidth(const Str_8& text) const;
|
|
|
|
|
|
|
|
float CalculateHeight(const Str_8& text) const;
|
|
|
|
|
|
|
|
UInt_64 CalculateIndexAtPoint(const Str_8& text, const Vec2_f& point) const;
|
|
|
|
|
2023-12-18 02:13:20 -08:00
|
|
|
Mesh Generate(Anchor anchor, const Str_8& text) const;
|
2023-12-17 03:29:08 -08:00
|
|
|
};
|
|
|
|
}
|