From e606b52c39516d0c29e62bad1dd851a929b9ab95 Mon Sep 17 00:00:00 2001 From: Shane Whitmire Date: Tue, 16 May 2023 19:43:58 -0500 Subject: [PATCH] PR 1690 Add font enable / disable smoothing Also added a check for whether the font is smoothing --- include/SFML/Graphics/Font.h | 29 +++++++++++++++++++++++++++++ src/SFML/Graphics/Font.cpp | 20 ++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/SFML/Graphics/Font.h b/include/SFML/Graphics/Font.h index f33b6911..32f456bf 100644 --- a/include/SFML/Graphics/Font.h +++ b/include/SFML/Graphics/Font.h @@ -161,6 +161,35 @@ CSFML_GRAPHICS_API float sfFont_getUnderlineThickness(const sfFont* font, unsign //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API const sfTexture* sfFont_getTexture(sfFont* font, unsigned int characterSize); +//////////////////////////////////////////////////////////// +/// \brief Enable or disable the smooth filter +/// +/// When the filter is activated, the font appears smoother +/// so that pixels are less noticeable. However if you want +/// the font to look exactly the same as its source file, +/// you should disable it. +/// The smooth filter is enabled by default. +/// +/// \param font Source font +/// \param smooth sfTrue to enable smoothing, sfFalse to disable it +/// +/// \see isSmooth +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfFont_setSmooth(sfFont* font, sfBool smooth); + +//////////////////////////////////////////////////////////// +/// \brief Tell whether the smooth filter is enabled or disabled +/// +/// \param font Source font +/// +/// \return sfTrue if smoothing is enabled, sfFalse if it is disabled +/// +/// \see setSmooth +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API const sfBool sfFont_isSmooth(const sfFont* font); + //////////////////////////////////////////////////////////// /// \brief Get the font information /// diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 7355d35d..58dd8d94 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -152,6 +152,26 @@ const sfTexture* sfFont_getTexture(sfFont* font, unsigned int characterSize) return &font->Textures[characterSize]; } + +//////////////////////////////////////////////////////////// +void sfFont_setSmooth(sfFont* font, sfBool smooth) +{ + font->This.setSmooth(smooth == sfTrue); +} + + +//////////////////////////////////////////////////////////// +const sfBool sfFont_isSmooth(const sfFont *font) +{ + if (font->This.isSmooth()) + { + return sfTrue; + } + + return sfFalse; +} + + //////////////////////////////////////////////////////////// sfFontInfo sfFont_getInfo(const sfFont* font) {