diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 356327d5d..622ed0298 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -380,7 +380,11 @@ void NzTextSprite::UpdateBoundingVolume() const NzVector3f down = m_scene->GetDown(); NzVector3f right = m_scene->GetRight(); - m_boundingVolume.Set(NzVector3f(0.f), static_cast(m_localBounds.width)*right + static_cast(m_localBounds.height)*down); + NzRectf bounds(m_localBounds); + NzVector2f max = bounds.GetMaximum(); + NzVector2f min = bounds.GetMinimum(); + + m_boundingVolume.Set(min.x*right + min.y*down, max.x*right + max.y*down); } if (!m_transformMatrixUpdated) diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 8e5577f48..64ac5a3ad 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -213,7 +213,6 @@ void NzSimpleTextDrawer::UpdateGlyphs() const // "Curseur" de dessin NzVector2ui drawPos(0, m_characterSize); - NzVector2ui lastPos(0, 0); m_glyphs.reserve(size); nzUInt32 previousCharacter = 0; @@ -294,9 +293,25 @@ void NzSimpleTextDrawer::UpdateGlyphs() const m_glyphs.push_back(glyph); - lastPos = drawPos; drawPos.x += advance; } - m_bounds.ExtendTo(lastPos); + // Calcul des bornes + if (!m_glyphs.empty()) + { + for (unsigned int i = 0; i < m_glyphs.size(); ++i) + { + Glyph& glyph = m_glyphs[i]; + + for (unsigned int j = 0; j < 4; ++j) + { + NzVector2ui corner(std::ceil(glyph.corners[j].x), std::ceil(glyph.corners[j].y)); + + if (i == 0 && j == 0) + m_bounds.Set(corner.x, corner.y, 0, 0); + else + m_bounds.ExtendTo(corner); + } + } + } }