Add a glyph quad to the vertex array
| 90 | |
| 91 | // Add a glyph quad to the vertex array |
| 92 | void addGlyphQuad(sf::VertexArray& vertices, sf::Vector2f position, sf::Color color, const sf::Glyph& glyph, float italicShear) |
| 93 | { |
| 94 | const sf::Vector2f padding(1.0f, 1.0f); |
| 95 | |
| 96 | const sf::Vector2f p1 = glyph.bounds.position - padding; |
| 97 | const sf::Vector2f p2 = glyph.bounds.position + glyph.bounds.size + padding; |
| 98 | |
| 99 | const auto uv1 = sf::Vector2f(glyph.textureRect.position) - padding; |
| 100 | const auto uv2 = sf::Vector2f(glyph.textureRect.position + glyph.textureRect.size) + padding; |
| 101 | |
| 102 | vertices.append({position + sf::Vector2f(p1.x - italicShear * p1.y, p1.y), color, {uv1.x, uv1.y}}); |
| 103 | vertices.append({position + sf::Vector2f(p2.x - italicShear * p1.y, p1.y), color, {uv2.x, uv1.y}}); |
| 104 | vertices.append({position + sf::Vector2f(p1.x - italicShear * p2.y, p2.y), color, {uv1.x, uv2.y}}); |
| 105 | vertices.append({position + sf::Vector2f(p1.x - italicShear * p2.y, p2.y), color, {uv1.x, uv2.y}}); |
| 106 | vertices.append({position + sf::Vector2f(p2.x - italicShear * p1.y, p1.y), color, {uv2.x, uv1.y}}); |
| 107 | vertices.append({position + sf::Vector2f(p2.x - italicShear * p2.y, p2.y), color, {uv2.x, uv2.y}}); |
| 108 | } |
| 109 | |
| 110 | struct TextSegment |
| 111 | { |
no test coverage detected