#pragma once #include #include #include #include #include #include #include #include #include class Font { public: Font(std::filesystem::path path, unsigned int height); using Quad = std::array; using Quads = std::vector; using TextureQuads = std::map; TextureQuads render(const utf8_string_view text) const; struct CharData { size_t textureIdx; glm::uvec2 size; glm::uvec2 position; glm::ivec2 bearing; long advance; }; struct FontTexture { glTexture texture; unsigned int used; }; static glm::uvec3 getTextureSize(unsigned int height); protected: void generateChars(const utf8_string_view text) const; const CharData getChar(char) const; std::size_t getTextureWithSpace(unsigned int adv) const; std::filesystem::path path; glm::uvec3 size; mutable std::map charsData; mutable std::vector fontTextures; };