diff options
Diffstat (limited to 'source/rendering')
-rw-r--r-- | source/rendering/StarFontTextureGroup.cpp | 8 | ||||
-rw-r--r-- | source/rendering/StarFontTextureGroup.hpp | 2 | ||||
-rw-r--r-- | source/rendering/StarTextPainter.cpp | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/source/rendering/StarFontTextureGroup.cpp b/source/rendering/StarFontTextureGroup.cpp index 76defee..e59d15c 100644 --- a/source/rendering/StarFontTextureGroup.cpp +++ b/source/rendering/StarFontTextureGroup.cpp @@ -45,7 +45,8 @@ const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Cha if (res.second) { m_font->setPixelSize(size); - Image image = m_font->render(c); + auto pair = m_font->render(c); + Image& image = pair.first; if (!processingDirectives.empty()) { try { Vec2F preSize = Vec2F(image.size()); @@ -55,7 +56,7 @@ const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Cha border->includeTransparent = true; } image = processImageOperations(imageOperations, image); - res.first->second.processingOffset = preSize - Vec2F(image.size()); + res.first->second.offset = (preSize - Vec2F(image.size())) / 2; } catch (StarException&) { image.forEachPixel([](unsigned x, unsigned y, Vec4B& pixel) { @@ -64,8 +65,9 @@ const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Cha } } else - res.first->second.processingOffset = Vec2F(); + res.first->second.offset = Vec2F(); + res.first->second.offset[1] += pair.second; res.first->second.texture = m_textureGroup->create(image); } diff --git a/source/rendering/StarFontTextureGroup.hpp b/source/rendering/StarFontTextureGroup.hpp index 15d2895..6bbb120 100644 --- a/source/rendering/StarFontTextureGroup.hpp +++ b/source/rendering/StarFontTextureGroup.hpp @@ -17,7 +17,7 @@ public: struct GlyphTexture { TexturePtr texture; int64_t time; - Vec2F processingOffset; + Vec2F offset; }; FontTextureGroup(TextureGroupPtr textureGroup); diff --git a/source/rendering/StarTextPainter.cpp b/source/rendering/StarTextPainter.cpp index c779c96..1d26e53 100644 --- a/source/rendering/StarTextPainter.cpp +++ b/source/rendering/StarTextPainter.cpp @@ -586,7 +586,7 @@ void TextPainter::renderGlyph(String::Char c, Vec2F const& screenPos, unsigned f return; const FontTextureGroup::GlyphTexture& glyphTexture = m_fontTextureGroup.glyphTexture(c, fontSize, processingDirectives); - Vec2F offset = glyphTexture.processingOffset * (scale * 0.5f); + Vec2F offset = glyphTexture.offset * scale; m_renderer->immediatePrimitives().emplace_back(std::in_place_type_t<RenderQuad>(), glyphTexture.texture, screenPos + offset, scale, color, 0.0f); } |