aboutsummaryrefslogtreecommitdiff
path: root/src/Text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text.cpp')
-rw-r--r--src/Text.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Text.cpp b/src/Text.cpp
index fa46277..c8da55c 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -11,7 +11,7 @@ namespace dchat
const float EMOJI_SCALE_WITH_TEXT = 1.0f;
const float EMOJI_SCALE_STANDALONE = 5.0f;
- Text::Text(const sf::Font &_font) :
+ Text::Text(const sf::Font *_font) :
font(_font),
characterSize(0),
maxWidth(0.0f),
@@ -23,7 +23,7 @@ namespace dchat
}
- Text::Text(const sf::String &_str, const sf::Font &_font, unsigned int _characterSize, float _maxWidth, bool _plainText) :
+ Text::Text(const sf::String &_str, const sf::Font *_font, unsigned int _characterSize, float _maxWidth, bool _plainText) :
font(_font),
characterSize(_characterSize),
vertices(sf::PrimitiveType::Quads),
@@ -150,8 +150,8 @@ namespace dchat
void Text::updateGeometry()
{
vertices.clear();
- float hspace = font.getGlyph(' ', characterSize, false).advance;
- float vspace = font.getLineSpacing(characterSize);
+ float hspace = font->getGlyph(' ', characterSize, false).advance;
+ float vspace = font->getLineSpacing(characterSize);
sf::Vector2f glyphPos;
sf::Uint32 prevCodePoint = 0;
@@ -215,7 +215,7 @@ namespace dchat
for(size_t i = 0; i < textElement.text.size; ++i)
{
sf::Uint32 codePoint = textElement.text[i];
- float kerning = font.getKerning(prevCodePoint, codePoint, characterSize);
+ float kerning = font->getKerning(prevCodePoint, codePoint, characterSize);
prevCodePoint = codePoint;
glyphPos.x += kerning;
@@ -254,7 +254,7 @@ namespace dchat
}
}
- const sf::Glyph &glyph = font.getGlyph(codePoint, characterSize, false);
+ const sf::Glyph &glyph = font->getGlyph(codePoint, characterSize, false);
if(glyphPos.x + glyph.advance > maxWidth)
{
// If there was a space in the text and text width is too long, then we need to word wrap at space index instead,
@@ -311,7 +311,7 @@ namespace dchat
dirty = false;
}
- float vspace = font.getLineSpacing(characterSize);
+ float vspace = font->getLineSpacing(characterSize);
sf::RenderStates states;
sf::Vector2f pos = position;
@@ -325,7 +325,7 @@ namespace dchat
if(pos.y + totalHeight <= 0.0f || pos.y >= target.getSize().y) return;
states.transform.translate(pos);
- states.texture = &font.getTexture(characterSize);
+ states.texture = &font->getTexture(characterSize);
target.draw(vertices, states);
for(TextElement &textElement : textElements)