summaryrefslogtreecommitdiff
path: root/include/SFML/Graphics/Text.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/SFML/Graphics/Text.hpp')
-rw-r--r--include/SFML/Graphics/Text.hpp87
1 files changed, 72 insertions, 15 deletions
diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp
index f3e389f..dae6ef2 100644
--- a/include/SFML/Graphics/Text.hpp
+++ b/include/SFML/Graphics/Text.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -145,6 +145,39 @@ public:
void setCharacterSize(unsigned int size);
////////////////////////////////////////////////////////////
+ /// \brief Set the line spacing factor
+ ///
+ /// The default spacing between lines is defined by the font.
+ /// This method enables you to set a factor for the spacing
+ /// between lines. By default the line spacing factor is 1.
+ ///
+ /// \param spacingFactor New line spacing factor
+ ///
+ /// \see getLineSpacing
+ ///
+ ////////////////////////////////////////////////////////////
+ void setLineSpacing(float spacingFactor);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Set the letter spacing factor
+ ///
+ /// The default spacing between letters is defined by the font.
+ /// This factor doesn't directly apply to the existing
+ /// spacing between each character, it rather adds a fixed
+ /// space between them which is calculated from the font
+ /// metrics and the character size.
+ /// Note that factors below 1 (including negative numbers) bring
+ /// characters closer to each other.
+ /// By default the letter spacing factor is 1.
+ ///
+ /// \param spacingFactor New letter spacing factor
+ ///
+ /// \see getLetterSpacing
+ ///
+ ////////////////////////////////////////////////////////////
+ void setLetterSpacing(float spacingFactor);
+
+ ////////////////////////////////////////////////////////////
/// \brief Set the text's style
///
/// You can pass a combination of one or more styles, for
@@ -261,6 +294,26 @@ public:
unsigned int getCharacterSize() const;
////////////////////////////////////////////////////////////
+ /// \brief Get the size of the letter spacing factor
+ ///
+ /// \return Size of the letter spacing factor
+ ///
+ /// \see setLetterSpacing
+ ///
+ ////////////////////////////////////////////////////////////
+ float getLetterSpacing() const;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Get the size of the line spacing factor
+ ///
+ /// \return Size of the line spacing factor
+ ///
+ /// \see setLineSpacing
+ ///
+ ////////////////////////////////////////////////////////////
+ float getLineSpacing() const;
+
+ ////////////////////////////////////////////////////////////
/// \brief Get the text's style
///
/// \return Text's style
@@ -382,17 +435,20 @@ private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
- String m_string; ///< String to display
- const Font* m_font; ///< Font used to display the string
- unsigned int m_characterSize; ///< Base size of characters, in pixels
- Uint32 m_style; ///< Text style (see Style enum)
- Color m_fillColor; ///< Text fill color
- Color m_outlineColor; ///< Text outline color
- float m_outlineThickness; ///< Thickness of the text's outline
- mutable VertexArray m_vertices; ///< Vertex array containing the fill geometry
- mutable VertexArray m_outlineVertices; ///< Vertex array containing the outline geometry
- mutable FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates)
- mutable bool m_geometryNeedUpdate; ///< Does the geometry need to be recomputed?
+ String m_string; ///< String to display
+ const Font* m_font; ///< Font used to display the string
+ unsigned int m_characterSize; ///< Base size of characters, in pixels
+ float m_letterSpacingFactor; ///< Spacing factor between letters
+ float m_lineSpacingFactor; ///< Spacing factor between lines
+ Uint32 m_style; ///< Text style (see Style enum)
+ Color m_fillColor; ///< Text fill color
+ Color m_outlineColor; ///< Text outline color
+ float m_outlineThickness; ///< Thickness of the text's outline
+ mutable VertexArray m_vertices; ///< Vertex array containing the fill geometry
+ mutable VertexArray m_outlineVertices; ///< Vertex array containing the outline geometry
+ mutable FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates)
+ mutable bool m_geometryNeedUpdate; ///< Does the geometry need to be recomputed?
+ mutable Uint64 m_fontTextureId; ///< The font texture id
};
} // namespace sf
@@ -411,8 +467,9 @@ private:
/// It inherits all the functions from sf::Transformable:
/// position, rotation, scale, origin. It also adds text-specific
/// properties such as the font to use, the character size,
-/// the font style (bold, italic, underlined, strike through), the
-/// global color and the text to display of course.
+/// the font style (bold, italic, underlined and strike through), the
+/// text color, the outline thickness, the outline color, the character
+/// spacing, the line spacing and the text to display of course.
/// It also provides convenience functions to calculate the
/// graphical size of the text, or to get the global position
/// of a given character.
@@ -445,7 +502,7 @@ private:
/// sf::Text text("hello", font);
/// text.setCharacterSize(30);
/// text.setStyle(sf::Text::Bold);
-/// text.setColor(sf::Color::Red);
+/// text.setFillColor(sf::Color::Red);
///
/// // Draw it
/// window.draw(text);