#ifndef FONT_H
#define FONT_H

#include "util.h"

struct asset;
struct work_startup_receipt;
struct renderer_startup_receipt;
struct asset_cache_startup_receipt;
struct ttf_startup_receipt;
struct resource_startup_receipt;

struct font_glyph {
    f32 off_x;
    f32 off_y;
    i32 advance;
    f32 width;
    f32 height;
    struct rect atlas_rect;
};

struct font {
    struct renderer_handle image_renderer_handle;
    u32 image_width;
    u32 image_height;
    f32 point_size;
    u16 glyphs_count;
    struct font_glyph *glyphs;
    u16 *lookup;
};

struct font_startup_receipt { i32 _; };
struct font_startup_receipt font_startup(struct work_startup_receipt *work_sr,
                                         struct renderer_startup_receipt *renderer_sr,
                                         struct asset_cache_startup_receipt *asset_cache_sr,
                                         struct ttf_startup_receipt *ttf_sr,
                                         struct resource_startup_receipt *resource_sr);

struct asset *font_load_asset(struct string path, f32 point_size, b32 help);
struct font *font_load_async(struct string path, f32 point_size);
struct font *font_load(struct string path, f32 point_size);

struct font_glyph *font_get_glyph(struct font *font, u32 codepoint);

#endif
