aboutsummaryrefslogtreecommitdiff
path: root/src/Text.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-03 07:35:39 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-03 07:35:42 +0200
commit9cde35c64c9f569055b101a80419d900f58806a9 (patch)
treecc94d0b5e7dab9c95e702905e4d5fc42f0253103 /src/Text.cpp
parent09080c571dbc959ab073aa6aa6598e6e447b0435 (diff)
Adding theming, add new theme 'simple'
Diffstat (limited to 'src/Text.cpp')
-rw-r--r--src/Text.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/Text.cpp b/src/Text.cpp
index 3cafc69..b22a27d 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -31,7 +31,8 @@ namespace dchat
color(sf::Color::White),
dirty(true),
plainText(_plainText),
- totalHeight(0.0f)
+ totalHeight(0.0f),
+ lineSpacing(0.0f)
{
setString(_str);
}
@@ -94,6 +95,15 @@ namespace dchat
}
}
+ void Text::setLineSpacing(float lineSpacing)
+ {
+ if(lineSpacing != this->lineSpacing)
+ {
+ this->lineSpacing = lineSpacing;
+ dirty = true;
+ }
+ }
+
float Text::getHeight() const
{
return totalHeight;
@@ -203,7 +213,7 @@ namespace dchat
if(glyphPos.x > maxWidth)
{
glyphPos.x = 0.0f;
- glyphPos.y += vspace;
+ glyphPos.y += vspace + lineSpacing;
}
continue;
@@ -244,12 +254,12 @@ namespace dchat
case '\n':
{
glyphPos.x = 0.0f;
- glyphPos.y += vspace;
+ glyphPos.y += vspace + lineSpacing;
continue;
}
case '\v':
{
- glyphPos.y += (vspace * TAB_WIDTH);
+ glyphPos.y += (vspace * TAB_WIDTH) + lineSpacing;
continue;
}
}
@@ -268,7 +278,7 @@ namespace dchat
{
sf::Vector2f &vertexPos = vertices[vertexOffset + j * 4 + k].position;
vertexPos.x -= lastSpacingAccumulatedOffset;
- vertexPos.y += vspace;
+ vertexPos.y += vspace + lineSpacing;
}
}
@@ -279,7 +289,7 @@ namespace dchat
else
glyphPos.x = 0.0f;
- glyphPos.y += vspace;
+ glyphPos.y += vspace + lineSpacing;
}
sf::Vector2f vertexTopLeft(glyphPos.x + glyph.bounds.left, glyphPos.y + glyph.bounds.top);
@@ -300,7 +310,7 @@ namespace dchat
glyphPos.x += glyph.advance;
}
}
- totalHeight = glyphPos.y + vspace;
+ totalHeight = glyphPos.y + lineSpacing + vspace;
}
void Text::draw(sf::RenderTarget &target, Cache &cache)