From df44f9344616e9d6e7009fcfedb6620087c1ff22 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Wed, 14 Dec 2022 15:57:48 +0100 Subject: Add lineHeightRatio to let text decide the line spacing --- src/graphics/text.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/graphics/text.h') 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 - Text::Text(Font &font, const std::string &text, + Text::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) -- cgit v1.2.3