#pragma once #include "../Texture.h" #include #include #include "../UserInterface/Engine/Geometry.h" class Text { double x, y; std::string content; Texture* texture = nullptr; static TTF_Font* font; static TTF_Font* iconFont; static float fontScale; // ui scale the fonts were last sized at static float iconFontScale; float textureScale = 1.0f; // ui scale this texture was rasterized at TTF_Font* overriddenFont = nullptr; double r = 1, g = 1, b = 1, a = 1; void createTexture(); static void EnsureFonts(); // opens/re-sizes the shared fonts for the current ui scale public: Text(double x, double y, std::string content, TTF_Font* font = nullptr); void SetText(const std::string& content); void SetPosition(double x, double y); void SetColor(double r, double g, double b, double a); void Render(); ~Text(); static void Init(); static TTF_Font* GetIconFont(); // shared material icons font, sized for the current ui scale static UI::Size Measure(std::string content); };