141 lines
2.8 KiB
C
141 lines
2.8 KiB
C
////////////////////////////////////////////////////////////
|
|
//~ Key types
|
|
|
|
Struct(GC_FontKey)
|
|
{
|
|
u64 v;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Run types
|
|
|
|
Struct(GC_RunRect)
|
|
{
|
|
Vec2 offset; /* Vector from baseline offset to top left of glyph rect */
|
|
f32 pos; /* Horizontal distance from start of baseline */
|
|
f32 advance;
|
|
|
|
Vec2 size;
|
|
G_Texture2DRef tex;
|
|
Rng2 uv;
|
|
};
|
|
|
|
Struct(GC_Run)
|
|
{
|
|
/* Run data */
|
|
Vec2 p0; /* Start of baseline to top-left-most rect */
|
|
Vec2 p1; /* Start of baseline to bottom-right-most rect corner */
|
|
u32 count;
|
|
GC_RunRect *rects;
|
|
|
|
/* Font stats */
|
|
f32 size;
|
|
f32 ascent;
|
|
f32 descent;
|
|
f32 cap;
|
|
|
|
b32 loaded;
|
|
};
|
|
|
|
extern Readonly GC_RunRect GC_NilRunRect;
|
|
extern Readonly GC_Run GC_NilRun;
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Key helpers
|
|
|
|
GC_FontKey GC_FontKeyFromResource(ResourceKey resource);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Run
|
|
|
|
GC_Run *GC_RunFromString(Arena *arena, GC_FontKey key, String str);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ////////////////////////////////////////////////////////////
|
|
// //~ Font types
|
|
|
|
// Struct(GC_FontKey)
|
|
// {
|
|
// u64 v;
|
|
// };
|
|
|
|
// Struct(GC_Glyph)
|
|
// {
|
|
// i32 advance;
|
|
// Vec2 baseline_offset;
|
|
// Vec2I32 atlas_p0;
|
|
// Vec2I32 atlas_p1;
|
|
// };
|
|
|
|
// Struct(GC_Font)
|
|
// {
|
|
// GPU_Resource *texture;
|
|
// u32 image_width;
|
|
// u32 image_height;
|
|
// u16 glyphs_count;
|
|
// F_Glyph *glyphs;
|
|
// u16 *lookup;
|
|
|
|
// /* Metrics */
|
|
// f32 size;
|
|
// f32 ascent;
|
|
// f32 descent;
|
|
// f32 cap;
|
|
// };
|
|
|
|
// ////////////////////////////////////////////////////////////
|
|
// //~ Run types
|
|
|
|
// Struct(F_RunRect)
|
|
// {
|
|
// Vec2 offset; /* Vector from baseline offset to top left of glyph rect */
|
|
// f32 pos; /* Horizontal distance from start of baseline */
|
|
// f32 advance;
|
|
// Vec2I32 atlas_p0;
|
|
// Vec2I32 atlas_p1;
|
|
// };
|
|
|
|
// Struct(F_Run)
|
|
// {
|
|
// Vec2 p0; /* Start of baseline to top-left-most rect */
|
|
// Vec2 p1; /* Start of baseline to bottom-right-most rect corner */
|
|
// u32 count;
|
|
// F_RunRect *rects;
|
|
// };
|
|
|
|
// ////////////////////////////////////////////////////////////
|
|
// //~ Font load job
|
|
|
|
// JobDecl(F_Load, { AC_Asset *asset; f32 size; ResourceKey resource; });
|
|
|
|
// ////////////////////////////////////////////////////////////
|
|
// //~ Font load
|
|
|
|
// AC_Asset *F_LoadAsset(ResourceKey resource, f32 size, b32 wait);
|
|
// F_Font *F_LoadFontAsync(ResourceKey resource, f32 size);
|
|
// F_Font *F_LoadFontWait(ResourceKey resource, f32 size);
|
|
|
|
// ////////////////////////////////////////////////////////////
|
|
// //~ Run
|
|
|
|
// F_Glyph F_GlyphFromCodepoint(F_Font *font, u32 codepoint);
|
|
// F_Run F_RunFromString(Arena *arena, F_Font *font, String str);
|