Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/rendering/StarFontTextureGroup.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-21 00:59:41 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-21 00:59:41 +1000
commitbd783d319557b41b5865d51f306a74abbf7af18c (patch)
tree5acefc369e7cbc42a1226efb0c28efb9a3d6830e /source/rendering/StarFontTextureGroup.cpp
parent9b75bd8eb280eb108d9eeef7a17c083a883155c7 (diff)
make the chat really pretty!!
also slightly optimized text shadow rendering, made sure glyphs with directives stay centered and added two extra Lua arguments to canvas.drawText
Diffstat (limited to 'source/rendering/StarFontTextureGroup.cpp')
-rw-r--r--source/rendering/StarFontTextureGroup.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/source/rendering/StarFontTextureGroup.cpp b/source/rendering/StarFontTextureGroup.cpp
index 038b535..7517c8b 100644
--- a/source/rendering/StarFontTextureGroup.cpp
+++ b/source/rendering/StarFontTextureGroup.cpp
@@ -12,24 +12,34 @@ void FontTextureGroup::cleanup(int64_t timeout) {
eraseWhere(m_glyphs, [&](auto const& p) { return currentTime - p.second.time > timeout; });
}
-TexturePtr FontTextureGroup::glyphTexture(String::Char c, unsigned size) {
- return glyphTexture(c, size, "");
-}
-
-TexturePtr FontTextureGroup::glyphTexture(String::Char c, unsigned size, String const& processingDirectives) {
+const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Char c, unsigned size, String const& processingDirectives)
+{
auto res = m_glyphs.insert(GlyphDescriptor{c, size, processingDirectives}, GlyphTexture());
if (res.second) {
m_font->setPixelSize(size);
Image image = m_font->render(c);
- if (!processingDirectives.empty())
+ if (!processingDirectives.empty()) {
+ Vec2F preSize = Vec2F(image.size());
image = processImageOperations(parseImageOperations(processingDirectives), image);
+ res.first->second.processingOffset = preSize - Vec2F(image.size());
+ }
+ else
+ res.first->second.processingOffset = Vec2F();
res.first->second.texture = m_textureGroup->create(image);
}
res.first->second.time = Time::monotonicMilliseconds();
- return res.first->second.texture;
+ return res.first->second;
+}
+
+TexturePtr FontTextureGroup::glyphTexturePtr(String::Char c, unsigned size) {
+ return glyphTexture(c, size, "").texture;
+}
+
+TexturePtr FontTextureGroup::glyphTexturePtr(String::Char c, unsigned size, String const& processingDirectives) {
+ return glyphTexture(c, size, processingDirectives).texture;
}
unsigned FontTextureGroup::glyphWidth(String::Char c, unsigned fontSize) {