summaryrefslogtreecommitdiff
path: root/src/graphics/text.h
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2022-12-14 15:57:48 +0100
committerEkaitz Zarraga <ekaitz@elenq.tech>2022-12-14 15:57:48 +0100
commitdf44f9344616e9d6e7009fcfedb6620087c1ff22 (patch)
treebf02c2a76b49dba9562f033137888d206f2be5e0 /src/graphics/text.h
parent02fe1199884d1056a3282268a8c75b3f086bfc9d (diff)
Add lineHeightRatio to let text decide the line spacingHEADmaster
Diffstat (limited to 'src/graphics/text.h')
-rw-r--r--src/graphics/text.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/graphics/text.h b/src/graphics/text.h
index f60980c..a390e8a 100644
--- a/src/graphics/text.h
+++ b/src/graphics/text.h
@@ -10,13 +10,14 @@ namespace Graphics {
Font &font_;
const std::string text_;
sf::VertexArray vertices_;
+ float lineHeightRatio_;
unsigned int size_, maxWidth_, maxHeight_;
void arrange(Font &font); // Specialize for sf::Font and TextureFont
public:
- Text(Font &font, const std::string &text, unsigned int maxWidth=0,
- unsigned int maxHeight=0);
+ Text(Font &font, const std::string &text, float lineHeightRatio=1.,
+ unsigned int maxWidth=0, unsigned int maxHeight=0);
void setFont(Font &font);
void setText(const std::string &text);
@@ -26,11 +27,12 @@ namespace Graphics {
};
template <typename Font>
- Text<Font>::Text(Font &font, const std::string &text,
+ Text<Font>::Text(Font &font, const std::string &text, float lineHeightRatio,
unsigned int maxWidth, unsigned int maxHeight)
: font_(font)
, text_(text)
, vertices_(sf::Quads, text.size()*4)
+ , lineHeightRatio_(lineHeightRatio)
, size_(0)
, maxWidth_(maxWidth)
, maxHeight_(maxHeight)