various UI and rt changes

This commit is contained in:
Dynamitos
2025-01-29 16:15:48 +01:00
parent 4e6eb02e74
commit e5ac354527
29 changed files with 314 additions and 223 deletions
+14 -12
View File
@@ -4,6 +4,7 @@
#include "Graphics/Texture.h"
#include "Math/Math.h"
#include <freetype/freetype.h>
#include <harfbuzz/hb.h>
namespace Seele {
class FontAsset : public Asset {
@@ -25,25 +26,26 @@ class FontAsset : public Asset {
void load(ArchiveBuffer& buffer);
};
struct FontData {
int32 ascent;
int32 descent;
int32 linegap;
Map<uint32, Glyph> glyphs;
};
const Glyph& getGlyphData(char c, uint32 fontSize) {
if (!fontSizes.contains(fontSize))
loadFontSize(fontSize);
return fontSizes[fontSize].glyphs[c];
}
const FontData& getFontData(uint32 fontSize) { return fontSizes[fontSize]; }
void loadFace();
struct RenderGlyph {
Gfx::PTexture2D texture;
UVector2 position;
UVector2 dimensions;
};
UVector2 shapeText(std::string_view view, uint32 fontSize, Array<RenderGlyph>& render);
private:
void loadFontSize(uint32 fontSize);
void loadGlyphs(uint32 fontSize);
Gfx::PGraphics graphics;
hb_blob_t* blob;
hb_face_t* hb_face;
hb_font_t* hb_font;
FT_Library ft;
FT_Face face;
Array<uint8> ttfFile;
FT_Face ft_face;
Array<char> ttfFile;
Map<uint32, FontData> fontSizes;
friend class FontLoader;
};