summaryrefslogtreecommitdiff
path: root/ui/text.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-26 17:48:11 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-26 17:48:11 +0000
commit30f58cc3832bd1b5a5cadf4b0a4a9d47d024f9f7 (patch)
tree0e347320e8295f03efb3d12bd85e76f838bf51d3 /ui/text.cpp
parentAlways set pixel unpack alignment before generating font texture content (diff)
downloadilt-30f58cc3832bd1b5a5cadf4b0a4a9d47d024f9f7.tar.bz2
ilt-30f58cc3832bd1b5a5cadf4b0a4a9d47d024f9f7.tar.xz
ilt-30f58cc3832bd1b5a5cadf4b0a4a9d47d024f9f7.zip
Remove the static font cache
Each thing can own/share a font rendering itself
Diffstat (limited to 'ui/text.cpp')
-rw-r--r--ui/text.cpp10
1 files changed, 2 insertions, 8 deletions
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 <array>
#include <cache.h>
-#include <filesystem>
#include <glArrays.h>
#include <glm/gtc/type_ptr.hpp>
-#include <map>
-#include <memory>
#include <utility>
-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<unsigned int>(pos.size.y))->render(s)) {
+ for (const auto & textureQuads : font.render(s)) {
auto & rendering
= models.emplace_back(textureQuads.first, static_cast<GLsizei>(6 * textureQuads.second.size()));
glBindVertexArray(rendering.vao);