#include "Fonts.h"
#include "DeerRender/DataStore.h"

namespace Deer {
	ImFont* normalText;
	ImFont* titleText;

	void initializeFonts() {
		ImGuiIO& io = ImGui::GetIO();
		io.Fonts->Clear();

		Path rfPath = "Editor/fonts/Roboto-Regular.ttf";
		Path faPath = "Editor/fonts/FontAwesome.otf";
		Path faNPath = "Editor/fonts/FontAwesome-Normal.otf";
		ImFontConfig cnfg;
		// cnfg.SizePixels = 26
		normalText = io.Fonts->AddFontFromFileTTF(rfPath.generic_string().c_str(), 18);

		ImFontConfig config;
		config.MergeMode = true;
		config.PixelSnapH = true;

    	ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 };
    	// Merge into normalText (18 px)
    	{
    	    ImFontConfig cfg;
    	    cfg.MergeMode = true;
			cfg.GlyphRanges = icons_ranges;
			cfg.GlyphMinAdvanceX = 18.0f;
    	    io.Fonts->AddFontFromFileTTF(faPath.generic_string().c_str(), 14, &cfg);
    	    io.Fonts->AddFontFromFileTTF(faNPath.generic_string().c_str(), 14, &cfg);
    	}

		titleText = io.Fonts->AddFontFromFileTTF(rfPath.generic_string().c_str(), 32);
    	// Merge into titleText (32 px)
    	{
    	    ImFontConfig cfg;
    	    cfg.MergeMode = true;
			cfg.GlyphRanges = icons_ranges;
			cfg.GlyphMinAdvanceX = 20.0f;
    	    io.Fonts->AddFontFromFileTTF(faPath.generic_string().c_str(), 20, &cfg);
    	    io.Fonts->AddFontFromFileTTF(faNPath.generic_string().c_str(), 20, &cfg);
    	}


    	io.Fonts->AddFontFromFileTTF(faPath.generic_string().c_str(), 18);

		io.Fonts->Build();
	}
} // namespace Deer
