From 912422f4862d8d78e247a6acef9716674ad45efa Mon Sep 17 00:00:00 2001 From: Corentin Schreiber Date: Wed, 20 Oct 2021 08:22:05 +0100 Subject: [PATCH] Partial revert from 40a0584636dab89f3fa1747e63f26fa895036ce1 This reverts the change to addLine(), which no longer had its outline drawn after the offending commit. --- src/SFML/Graphics/Text.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index 9915eb888..a32c4439e 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -34,17 +34,17 @@ namespace { // Add an underline or strikethrough line to the vertex array - void addLine(sf::VertexArray& vertices, float lineLength, float lineTop, const sf::Color& color, float offset, float thickness) + void addLine(sf::VertexArray& vertices, float lineLength, float lineTop, const sf::Color& color, float offset, float thickness, float outlineThickness = 0) { float top = std::floor(lineTop + offset - (thickness / 2) + 0.5f); float bottom = top + std::floor(thickness + 0.5f); - vertices.append(sf::Vertex(sf::Vector2f(0, top), color, sf::Vector2f(1, 1))); - vertices.append(sf::Vertex(sf::Vector2f(lineLength, top), color, sf::Vector2f(1, 1))); - vertices.append(sf::Vertex(sf::Vector2f(0, bottom), color, sf::Vector2f(1, 1))); - vertices.append(sf::Vertex(sf::Vector2f(0, bottom), color, sf::Vector2f(1, 1))); - vertices.append(sf::Vertex(sf::Vector2f(lineLength, top), color, sf::Vector2f(1, 1))); - vertices.append(sf::Vertex(sf::Vector2f(lineLength, bottom), color, sf::Vector2f(1, 1))); + vertices.append(sf::Vertex(sf::Vector2f(-outlineThickness, top - outlineThickness), color, sf::Vector2f(1, 1))); + vertices.append(sf::Vertex(sf::Vector2f(lineLength + outlineThickness, top - outlineThickness), color, sf::Vector2f(1, 1))); + vertices.append(sf::Vertex(sf::Vector2f(-outlineThickness, bottom + outlineThickness), color, sf::Vector2f(1, 1))); + vertices.append(sf::Vertex(sf::Vector2f(-outlineThickness, bottom + outlineThickness), color, sf::Vector2f(1, 1))); + vertices.append(sf::Vertex(sf::Vector2f(lineLength + outlineThickness, top - outlineThickness), color, sf::Vector2f(1, 1))); + vertices.append(sf::Vertex(sf::Vector2f(lineLength + outlineThickness, bottom + outlineThickness), color, sf::Vector2f(1, 1))); } // Add a glyph quad to the vertex array @@ -459,7 +459,7 @@ void Text::ensureGeometryUpdate() const addLine(m_vertices, x, y, m_fillColor, underlineOffset, underlineThickness); if (m_outlineThickness != 0) - addLine(m_outlineVertices, x, y, m_outlineColor, underlineOffset, underlineThickness); + addLine(m_outlineVertices, x, y, m_outlineColor, underlineOffset, underlineThickness, m_outlineThickness); } // If we're using the strike through style and there's a new line, draw a line across all characters @@ -468,7 +468,7 @@ void Text::ensureGeometryUpdate() const addLine(m_vertices, x, y, m_fillColor, strikeThroughOffset, underlineThickness); if (m_outlineThickness != 0) - addLine(m_outlineVertices, x, y, m_outlineColor, strikeThroughOffset, underlineThickness); + addLine(m_outlineVertices, x, y, m_outlineColor, strikeThroughOffset, underlineThickness, m_outlineThickness); } prevChar = curChar; @@ -545,7 +545,7 @@ void Text::ensureGeometryUpdate() const addLine(m_vertices, x, y, m_fillColor, underlineOffset, underlineThickness); if (m_outlineThickness != 0) - addLine(m_outlineVertices, x, y, m_outlineColor, underlineOffset, underlineThickness); + addLine(m_outlineVertices, x, y, m_outlineColor, underlineOffset, underlineThickness, m_outlineThickness); } // If we're using the strike through style, add the last line across all characters @@ -554,7 +554,7 @@ void Text::ensureGeometryUpdate() const addLine(m_vertices, x, y, m_fillColor, strikeThroughOffset, underlineThickness); if (m_outlineThickness != 0) - addLine(m_outlineVertices, x, y, m_outlineColor, strikeThroughOffset, underlineThickness); + addLine(m_outlineVertices, x, y, m_outlineColor, strikeThroughOffset, underlineThickness, m_outlineThickness); } // Update the bounding rectangle