#pragma once

#include "../render.h"
#include "../core/object.h"
#include "../texture.h"
#include <common.h>
#include <vector>
#include <string>
#include <map>

namespace render::text{

class Font
{
    friend class text;
    struct drawGlyphInfo
    {
        uint32_t code;
        vec2f pos;
        vec4f color;
        vec4f background;
    };

    struct charInfo
    {
        uint32_t code;
        vec4f texCoord;
        vec2i32 size;
        vec2i32 imgSize;
        vec2f offset;
    };

public:
    Font();
    Font(const std::string &path);

    bool load(const std::string &path);
    bool loadQuad(const std::string &path);
    void draw(const drawGlyphInfo*, uint32_t, float scale) const;
    float maxHeight();

    charInfo **glyphTable;
protected:
    float _maxHeight;
    std::map<std::pair<uint16_t, uint16_t>, float> _kerningPairs;

    render::texture _tex;
    float defaultScale;
    std::vector<charInfo> _charList;
    charInfo *_symbols[0xFFFF];
};

}
