Skip to content

Commit

Permalink
PR 1690 Add font enable / disable smoothing
Browse files Browse the repository at this point in the history
Also added a check for whether the font is smoothing
  • Loading branch information
dogunbound authored and eXpl0it3r committed Jun 26, 2023
1 parent 7cbcd8f commit e606b52
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
29 changes: 29 additions & 0 deletions include/SFML/Graphics/Font.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
20 changes: 20 additions & 0 deletions src/SFML/Graphics/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit e606b52

Please sign in to comment.