MCPcopy Create free account
hub / github.com/SFML/SFML / addGlyphQuad

Function addGlyphQuad

src/SFML/Graphics/Text.cpp:92–108  ·  view source on GitHub ↗

Add a glyph quad to the vertex array

Source from the content-addressed store, hash-verified

90
91// Add a glyph quad to the vertex array
92void 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
110struct TextSegment
111{

Callers 1

ensureGeometryUpdateMethod · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected