81 lines
1.5 KiB
C
81 lines
1.5 KiB
C
////////////////////////////////
|
|
//~ Font types
|
|
|
|
Struct(F_Glyph)
|
|
{
|
|
f32 off_x;
|
|
f32 off_y;
|
|
f32 width;
|
|
f32 height;
|
|
i32 advance;
|
|
Rect atlas_rect;
|
|
};
|
|
|
|
Struct(F_Font)
|
|
{
|
|
GPU_Resource *texture;
|
|
u32 image_width;
|
|
u32 image_height;
|
|
f32 point_size;
|
|
u16 glyphs_count;
|
|
F_Glyph *glyphs;
|
|
u16 *lookup;
|
|
};
|
|
|
|
////////////////////////////////
|
|
//~ Font job types
|
|
|
|
Struct(F_LoadJobSig)
|
|
{
|
|
F_LoadJobSig *next_free;
|
|
|
|
AC_Asset *asset;
|
|
f32 point_size;
|
|
u64 path_len;
|
|
char path_cstr[1024];
|
|
};
|
|
|
|
Struct(F_LoadJobSigStore)
|
|
{
|
|
F_LoadJobSig *head_free;
|
|
Arena *arena;
|
|
P_Mutex mutex;
|
|
};
|
|
|
|
////////////////////////////////
|
|
//~ Shared state
|
|
|
|
#define F_LookupTableSize (256)
|
|
|
|
Struct(F_SharedState)
|
|
{
|
|
F_LoadJobSigStore params;
|
|
};
|
|
|
|
extern F_SharedState F_shared_state;
|
|
|
|
////////////////////////////////
|
|
//~ Startup
|
|
|
|
Struct(F_StartupReceipt) { i32 _; };
|
|
F_StartupReceipt F_Startup(AC_StartupReceipt *asset_cache_sr, TTF_StartupReceipt *ttf_sr);
|
|
|
|
////////////////////////////////
|
|
//~ Font load job
|
|
|
|
F_LoadJobSig *F_AllocJobSig(void);
|
|
void F_ReleaseJobSig(F_LoadJobSig *p);
|
|
P_JobDef(F_LoadAssetJob, job);
|
|
|
|
////////////////////////////////
|
|
//~ Font load operations
|
|
|
|
AC_Asset *F_LoadAsset(String path, f32 point_size, b32 wait);
|
|
F_Font *F_LoadFontAsync(String path, f32 point_size);
|
|
F_Font *F_LoadFontWait(String path, f32 point_size);
|
|
|
|
////////////////////////////////
|
|
//~ Font data operations
|
|
|
|
F_Glyph *F_GetGlyph(F_Font *font, u32 codepoint);
|