#ifndef _H_FTFONT_H
#define _H_FTFONT_H

#include <ft2build.h>
#include FT_FREETYPE_H

#include <iostream>
#include <filesystem>
#include <glm/glm.hpp>
#include <map>
#include <unordered_map>

class Text {
private:
	struct Font {
		struct Character {
			unsigned int TextureID;
			glm::ivec2 Size;
			glm::ivec2 Bearing;
			unsigned int Advance;
		};
		std::map<char, Character> characters;
	};

	std::unordered_map<std::string, Font> fonts;
	unsigned int programID = 0;
	unsigned int VAO = 0, VBO = 0;
	unsigned int colorPos = 0;
	unsigned int projPos = 0;
	glm::mat4 projMatrix = glm::mat4(1.f);

public:
	Text();
	bool loadFonts(const std::string& font_folder);

	void setProjectionMatrix(const glm::mat4& proj) { projMatrix = proj; }

	void DrawText(
		const std::string& fontName, 
		const std::string& text, 
		const glm::vec2& position,
		float scale, 
		const glm::vec4& color = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)
	);
	void DrawTextOutline(
		const std::string& fontName, 
		const std::string& text, 
		const glm::vec2& position,
		float scale, 
		const glm::vec4& color = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)
	);
};

#endif // _H_FTFONT_H
