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

summaryrefslogtreecommitdiff
path: root/source/rendering/StarTextPainter.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/StarTextPainter.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/StarTextPainter.cpp')
-rw-r--r--source/rendering/StarTextPainter.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/source/rendering/StarTextPainter.cpp b/source/rendering/StarTextPainter.cpp
index 0ef374d..205aefe 100644
--- a/source/rendering/StarTextPainter.cpp
+++ b/source/rendering/StarTextPainter.cpp
@@ -379,9 +379,16 @@ RectF TextPainter::doRenderGlyph(String::Char c, TextPositioning const& position
if (reallyRender) {
if ((int)m_renderSettings.mode & (int)FontMode::Shadow) {
Color shadow = Color::Black;
- shadow.setAlpha(m_renderSettings.color[3]);
+ uint8_t alphaU = m_renderSettings.color[3];
+ if (alphaU != 255) {
+ float alpha = byteToFloat(alphaU);
+ shadow.setAlpha(floatToByte(alpha * (1.5f - 0.5f * alpha)));
+ }
+ else
+ shadow.setAlpha(alphaU);
+
+ //Kae: Draw only one shadow glyph instead of stacking two, alpha modified to appear perceptually the same as vanilla
renderGlyph(c, position.pos + Vec2F(hOffset, vOffset - 2), m_fontSize, 1, shadow.toRgba(), m_processingDirectives);
- renderGlyph(c, position.pos + Vec2F(hOffset, vOffset - 1), m_fontSize, 1, shadow.toRgba(), m_processingDirectives);
}
renderGlyph(c, position.pos + Vec2F(hOffset, vOffset), m_fontSize, 1, m_renderSettings.color, m_processingDirectives);
@@ -395,8 +402,9 @@ void TextPainter::renderGlyph(String::Char c, Vec2F const& screenPos, unsigned f
if (!fontSize)
return;
- auto texture = m_fontTextureGroup.glyphTexture(c, fontSize, processingDirectives);
- m_renderer->render(renderTexturedRect(move(texture), Vec2F(screenPos), scale, color, 0.0f));
+ const FontTextureGroup::GlyphTexture& glyphTexture = m_fontTextureGroup.glyphTexture(c, fontSize, processingDirectives);
+ Vec2F offset = glyphTexture.processingOffset * (scale * 0.5f); //Kae: Re-center the glyph if the image scale was changed by the directives (it is positioned from the bottom left)
+ m_renderer->render(renderTexturedRect(glyphTexture.texture, Vec2F(screenPos) + offset, scale, color, 0.0f));
}
}