diff --git a/include/SFML/Graphics/Font.h b/include/SFML/Graphics/Font.h index 1c028b9..9b1aa09 100644 --- a/include/SFML/Graphics/Font.h +++ b/include/SFML/Graphics/Font.h @@ -88,15 +88,16 @@ CSFML_GRAPHICS_API void sfFont_destroy(sfFont* font); //////////////////////////////////////////////////////////// /// \brief Get a glyph in a font /// -/// \param font Source font -/// \param codePoint Unicode code point of the character to get -/// \param characterSize Character size, in pixels -/// \param bold Retrieve the bold version or the regular one? +/// \param font Source font +/// \param codePoint Unicode code point of the character to get +/// \param characterSize Character size, in pixels +/// \param bold Retrieve the bold version or the regular one? +/// \param outlineThickness Thickness of outline (when != 0 the glyph will not be filled) /// /// \return The corresponding glyph /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API sfGlyph sfFont_getGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold); +CSFML_GRAPHICS_API sfGlyph sfFont_getGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold, float outlineThickness); //////////////////////////////////////////////////////////// /// \brief Get the kerning value corresponding to a given pair of characters in a font diff --git a/include/SFML/Graphics/Text.h b/include/SFML/Graphics/Text.h index ff9383f..0eaa6d3 100644 --- a/include/SFML/Graphics/Text.h +++ b/include/SFML/Graphics/Text.h @@ -290,16 +290,60 @@ CSFML_GRAPHICS_API void sfText_setCharacterSize(sfText* text, unsigned int size) CSFML_GRAPHICS_API void sfText_setStyle(sfText* text, sfUint32 style); //////////////////////////////////////////////////////////// -/// \brief Set the global color of a text +/// \brief Set the fill color of a text /// -/// By default, the text's color is opaque white. +/// By default, the text's fill color is opaque white. +/// Setting the fill color to a transparent color with an outline +/// will cause the outline to be displayed in the fill area of the text. /// /// \param text Text object -/// \param color New color of the text +/// \param color New fill color of the text +/// +/// \deprecated This function is deprecated and may be removed in future releases. +/// Use sfText_setFillColor instead. /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfText_setColor(sfText* text, sfColor color); +//////////////////////////////////////////////////////////// +/// \brief Set the fill color of a text +/// +/// By default, the text's fill color is opaque white. +/// Setting the fill color to a transparent color with an outline +/// will cause the outline to be displayed in the fill area of the text. +/// +/// \param text Text object +/// \param color New fill color of the text +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfText_setFillColor(sfText* text, sfColor color); + +//////////////////////////////////////////////////////////// +/// \brief Set the outline color of the text +/// +/// By default, the text's outline color is opaque black. +/// +/// \param text Text object +/// \param color New outline color of the text +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfText_setOutlineColor(sfText* text, sfColor color); + +//////////////////////////////////////////////////////////// +/// \brief Set the thickness of the text's outline +/// +/// By default, the outline thickness is 0. +/// +/// Be aware that using a negative value for the outline +/// thickness will cause distorted rendering. +/// +/// \param thickness New outline thickness, in pixels +/// +/// \see getOutlineThickness +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfText_setOutlineThickness(sfText* text, float thickness); + //////////////////////////////////////////////////////////// /// \brief Get the string of a text (returns an ANSI string) /// @@ -355,15 +399,48 @@ CSFML_GRAPHICS_API unsigned int sfText_getCharacterSize(const sfText* text); CSFML_GRAPHICS_API sfUint32 sfText_getStyle(const sfText* text); //////////////////////////////////////////////////////////// -/// \brief Get the global color of a text +/// \brief Get the fill color of a text /// /// \param text Text object /// -/// \return Global color of the text +/// \return Fill color of the text +/// +/// \deprecated This function is deprecated and may be removed in future releases. +/// Use sfText_getFillColor instead. /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfColor sfText_getColor(const sfText* text); +//////////////////////////////////////////////////////////// +/// \brief Get the fill color of a text +/// +/// \param text Text object +/// +/// \return Fill color of the text +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfColor sfText_getFillColor(const sfText* text); + +//////////////////////////////////////////////////////////// +/// \brief Get the outline color of a text +/// +/// \param text Text object +/// +/// \return Outline color of the text +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfColor sfText_getOutlineColor(const sfText* text); + +//////////////////////////////////////////////////////////// +/// \brief Get the outline thickness of a text +/// +/// \param text Text object +/// +/// \return Outline thickness of a text, in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API float sfText_getOutlineThickness(const sfText* text); + //////////////////////////////////////////////////////////// /// \brief Return the position of the \a index-th character in a text /// diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index b2b82a7..1f54e4a 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -93,12 +93,12 @@ void sfFont_destroy(sfFont* font) //////////////////////////////////////////////////////////// -sfGlyph sfFont_getGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold) +sfGlyph sfFont_getGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold, float outlineThickness) { sfGlyph glyph = {0, {0, 0, 0, 0}, {0, 0, 0, 0}}; CSFML_CHECK_RETURN(font, glyph); - sf::Glyph SFMLGlyph = font->This.getGlyph(codePoint, characterSize, bold == sfTrue); + sf::Glyph SFMLGlyph = font->This.getGlyph(codePoint, characterSize, bold == sfTrue, outlineThickness); glyph.advance = SFMLGlyph.advance; glyph.bounds.left = SFMLGlyph.bounds.left; diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index cd6e51c..27578ed 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -219,7 +219,28 @@ void sfText_setStyle(sfText* text, sfUint32 style) //////////////////////////////////////////////////////////// void sfText_setColor(sfText* text, sfColor color) { - CSFML_CALL(text, setColor(sf::Color(color.r, color.g, color.b, color.a))); + sfText_setFillColor(text, color); +} + + +//////////////////////////////////////////////////////////// +void sfText_setFillColor(sfText* text, sfColor color) +{ + CSFML_CALL(text, setFillColor(sf::Color(color.r, color.g, color.b, color.a))); +} + + +//////////////////////////////////////////////////////////// +void sfText_setOutlineColor(sfText* text, sfColor color) +{ + CSFML_CALL(text, setOutlineColor(sf::Color(color.r, color.g, color.b, color.a))); +} + + +//////////////////////////////////////////////////////////// +void sfText_setOutlineThickness(sfText* text, float thickness) +{ + CSFML_CALL(text, setOutlineThickness(thickness)); } @@ -268,11 +289,18 @@ sfUint32 sfText_getStyle(const sfText* text) //////////////////////////////////////////////////////////// sfColor sfText_getColor(const sfText* text) +{ + return sfText_getFillColor(text); +} + + +//////////////////////////////////////////////////////////// +sfColor sfText_getFillColor(const sfText* text) { sfColor color = {0, 0, 0, 0}; CSFML_CHECK_RETURN(text, color); - sf::Color sfmlColor = text->This.getColor(); + sf::Color sfmlColor = text->This.getFillColor(); color.r = sfmlColor.r; color.g = sfmlColor.g; color.b = sfmlColor.b; @@ -282,6 +310,29 @@ sfColor sfText_getColor(const sfText* text) } +//////////////////////////////////////////////////////////// +sfColor sfText_getOutlineColor(const sfText* text) +{ + sfColor color = { 0, 0, 0, 0 }; + CSFML_CHECK_RETURN(text, color); + + sf::Color sfmlColor = text->This.getOutlineColor(); + color.r = sfmlColor.r; + color.g = sfmlColor.g; + color.b = sfmlColor.b; + color.a = sfmlColor.a; + + return color; +} + + +//////////////////////////////////////////////////////////// +float sfText_getOutlineThickness(const sfText* text) +{ + CSFML_CALL_RETURN(text, getOutlineThickness(), 0.f); +} + + //////////////////////////////////////////////////////////// sfVector2f sfText_findCharacterPos(const sfText* text, size_t index) {