diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-03 14:21:51 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-03 14:21:51 +1000 |
commit | d018957b098f00536d0d7641e13aaf1ebddf2238 (patch) | |
tree | 0a739eb78c402dd261e06381f77c822c607922ad /source/rendering/StarFontTextureGroup.cpp | |
parent | 069d61e487947a8be38f6a3db52695db94fd306e (diff) |
Fix font glyph generation to work correctly with other fonts
Diffstat (limited to 'source/rendering/StarFontTextureGroup.cpp')
-rw-r--r-- | source/rendering/StarFontTextureGroup.cpp | 8 |
1 files changed, 5 insertions, 3 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); } |