From 30f58cc3832bd1b5a5cadf4b0a4a9d47d024f9f7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 26 Jan 2024 17:48:11 +0000 Subject: Remove the static font cache Each thing can own/share a font rendering itself --- ui/text.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'ui/text.cpp') diff --git a/ui/text.cpp b/ui/text.cpp index b776b90..7cb7d30 100644 --- a/ui/text.cpp +++ b/ui/text.cpp @@ -4,19 +4,13 @@ #include "uiComponent.h" #include #include -#include #include #include -#include -#include #include -const std::filesystem::path font {"/usr/share/fonts/hack/Hack-Regular.ttf"}; - -Text::Text(std::string_view s, Position pos, glm::vec3 c) : UIComponent {pos}, colour {c} +Text::Text(std::string_view s, const Font & font, Position pos, glm::vec3 c) : UIComponent {pos}, colour {c} { - for (const auto & textureQuads : - Font::cachedFontRenderings.get(font, static_cast(pos.size.y))->render(s)) { + for (const auto & textureQuads : font.render(s)) { auto & rendering = models.emplace_back(textureQuads.first, static_cast(6 * textureQuads.second.size())); glBindVertexArray(rendering.vao); -- cgit v1.2.3