mirror of
https://github.com/SFML/SFML.git
synced 2025-01-19 15:55:13 +08:00
Fixed bug in sf::Text when applying an outline color/thickness
When applying an outline thickness to sf::Text in combination with a strikethrough and/or an underlined style, the ensureGeometryUpdate function adds unwanted vertices if the string contains two consecutive '\n' charecter. To fix this we need to add an additional check in the if statements to check if both the current and previous character it's a new line character.
This commit is contained in:
parent
44d3e26766
commit
bcb013b45b
@ -444,12 +444,15 @@ void Text::ensureGeometryUpdate() const
|
||||
{
|
||||
Uint32 curChar = m_string[i];
|
||||
|
||||
// Skip the \r char to avoid weird graphical issues
|
||||
if (curChar == '\r')
|
||||
continue;
|
||||
|
||||
// Apply the kerning offset
|
||||
x += m_font->getKerning(prevChar, curChar, m_characterSize);
|
||||
prevChar = curChar;
|
||||
|
||||
// If we're using the underlined style and there's a new line, draw a line
|
||||
if (isUnderlined && (curChar == L'\n'))
|
||||
if (isUnderlined && (curChar == L'\n' && prevChar != L'\n'))
|
||||
{
|
||||
addLine(m_vertices, x, y, m_fillColor, underlineOffset, underlineThickness);
|
||||
|
||||
@ -458,7 +461,7 @@ void Text::ensureGeometryUpdate() const
|
||||
}
|
||||
|
||||
// If we're using the strike through style and there's a new line, draw a line across all characters
|
||||
if (isStrikeThrough && (curChar == L'\n'))
|
||||
if (isStrikeThrough && (curChar == L'\n' && prevChar != L'\n'))
|
||||
{
|
||||
addLine(m_vertices, x, y, m_fillColor, strikeThroughOffset, underlineThickness);
|
||||
|
||||
@ -466,6 +469,8 @@ void Text::ensureGeometryUpdate() const
|
||||
addLine(m_outlineVertices, x, y, m_outlineColor, strikeThroughOffset, underlineThickness, m_outlineThickness);
|
||||
}
|
||||
|
||||
prevChar = curChar;
|
||||
|
||||
// Handle special characters
|
||||
if ((curChar == L' ') || (curChar == L'\n') || (curChar == L'\t'))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user