diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-02 01:32:02 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-02 01:32:02 +0000 |
commit | cf64ce9a1312de5e9a76bb3f43105a4eac59eb15 (patch) | |
tree | 7ddf3d3bfc7a7add7a8eacde3862206cd2fd5ec4 /ui/text.cpp | |
parent | Cache allows multiple key parts (diff) | |
download | ilt-cf64ce9a1312de5e9a76bb3f43105a4eac59eb15.tar.bz2 ilt-cf64ce9a1312de5e9a76bb3f43105a4eac59eb15.tar.xz ilt-cf64ce9a1312de5e9a76bb3f43105a4eac59eb15.zip |
Use Cache system to persist font rendering for Text
Diffstat (limited to 'ui/text.cpp')
-rw-r--r-- | ui/text.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ui/text.cpp b/ui/text.cpp index 2acfb7e..0c372a1 100644 --- a/ui/text.cpp +++ b/ui/text.cpp @@ -3,15 +3,19 @@ #include "gfx/gl/uiShader.h" #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 auto font {"/usr/share/fonts/hack/Hack-Regular.ttf"}; +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} { - for (const auto & textureQuads : Font {font, static_cast<unsigned int>(pos.size.y)}.render(s)) { + for (const auto & textureQuads : + Font::cachedFontRenderings.get(font, static_cast<unsigned int>(pos.size.y))->render(s)) { auto & rendering = models.emplace_back(textureQuads.first, static_cast<GLsizei>(6 * textureQuads.second.size())); glBindVertexArray(rendering.vao); |