mirror of
https://github.com/SFML/SFML.git
synced 2024-12-01 15:51:04 +08:00
Fix corelation between text setOutlineThickness() and getLocalBounds()
This fixes text crawling explained in issue #2129
This commit is contained in:
parent
2bca810025
commit
2db12350e7
@ -500,19 +500,8 @@ void Text::ensureGeometryUpdate() const
|
|||||||
{
|
{
|
||||||
const Glyph& glyph = m_font->getGlyph(curChar, m_characterSize, isBold, m_outlineThickness);
|
const Glyph& glyph = m_font->getGlyph(curChar, m_characterSize, isBold, m_outlineThickness);
|
||||||
|
|
||||||
float left = glyph.bounds.left;
|
|
||||||
float top = glyph.bounds.top;
|
|
||||||
float right = glyph.bounds.left + glyph.bounds.width;
|
|
||||||
float bottom = glyph.bounds.top + glyph.bounds.height;
|
|
||||||
|
|
||||||
// Add the outline glyph to the vertices
|
// Add the outline glyph to the vertices
|
||||||
addGlyphQuad(m_outlineVertices, Vector2f(x, y), m_outlineColor, glyph, italicShear);
|
addGlyphQuad(m_outlineVertices, Vector2f(x, y), m_outlineColor, glyph, italicShear);
|
||||||
|
|
||||||
// Update the current bounds with the outlined glyph bounds
|
|
||||||
minX = std::min(minX, x + left - italicShear * bottom);
|
|
||||||
maxX = std::max(maxX, x + right - italicShear * top);
|
|
||||||
minY = std::min(minY, y + top);
|
|
||||||
maxY = std::max(maxY, y + bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the current glyph's description
|
// Extract the current glyph's description
|
||||||
@ -521,9 +510,7 @@ void Text::ensureGeometryUpdate() const
|
|||||||
// Add the glyph to the vertices
|
// Add the glyph to the vertices
|
||||||
addGlyphQuad(m_vertices, Vector2f(x, y), m_fillColor, glyph, italicShear);
|
addGlyphQuad(m_vertices, Vector2f(x, y), m_fillColor, glyph, italicShear);
|
||||||
|
|
||||||
// Update the current bounds with the non outlined glyph bounds
|
// Update the current bounds
|
||||||
if (m_outlineThickness == 0)
|
|
||||||
{
|
|
||||||
float left = glyph.bounds.left;
|
float left = glyph.bounds.left;
|
||||||
float top = glyph.bounds.top;
|
float top = glyph.bounds.top;
|
||||||
float right = glyph.bounds.left + glyph.bounds.width;
|
float right = glyph.bounds.left + glyph.bounds.width;
|
||||||
@ -533,12 +520,21 @@ void Text::ensureGeometryUpdate() const
|
|||||||
maxX = std::max(maxX, x + right - italicShear * top);
|
maxX = std::max(maxX, x + right - italicShear * top);
|
||||||
minY = std::min(minY, y + top);
|
minY = std::min(minY, y + top);
|
||||||
maxY = std::max(maxY, y + bottom);
|
maxY = std::max(maxY, y + bottom);
|
||||||
}
|
|
||||||
|
|
||||||
// Advance to the next character
|
// Advance to the next character
|
||||||
x += glyph.advance + letterSpacing;
|
x += glyph.advance + letterSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're using outline, update the current bounds
|
||||||
|
if (m_outlineThickness != 0)
|
||||||
|
{
|
||||||
|
float outline = std::abs(std::ceil(m_outlineThickness));
|
||||||
|
minX -= outline;
|
||||||
|
maxX += outline;
|
||||||
|
minY -= outline;
|
||||||
|
maxY += outline;
|
||||||
|
}
|
||||||
|
|
||||||
// If we're using the underlined style, add the last line
|
// If we're using the underlined style, add the last line
|
||||||
if (isUnderlined && (x > 0))
|
if (isUnderlined && (x > 0))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user