Default all sf::Font special member functions

This commit is contained in:
Chris Thrasher 2023-11-17 11:54:57 -07:00
parent c1f92ed020
commit 08eca7c9a4
3 changed files with 4 additions and 97 deletions

View File

@ -66,42 +66,6 @@ public:
std::string family; //!< The font family
};
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// This constructor defines an empty font
///
////////////////////////////////////////////////////////////
Font();
////////////////////////////////////////////////////////////
/// \brief Copy constructor
///
/// \param copy Instance to copy
///
////////////////////////////////////////////////////////////
Font(const Font& copy);
////////////////////////////////////////////////////////////
/// \brief Move constructor
///
////////////////////////////////////////////////////////////
Font(Font&&) noexcept;
////////////////////////////////////////////////////////////
/// \brief Move assignment
///
////////////////////////////////////////////////////////////
Font& operator=(Font&&) noexcept;
////////////////////////////////////////////////////////////
/// \brief Destructor
///
/// Cleans up all the internal resources used by the font
///
////////////////////////////////////////////////////////////
~Font();
////////////////////////////////////////////////////////////
/// \brief Load the font from a file
///
@ -317,16 +281,6 @@ public:
////////////////////////////////////////////////////////////
bool isSmooth() const;
////////////////////////////////////////////////////////////
/// \brief Overload of assignment operator
///
/// \param right Instance to assign
///
/// \return Reference to self
///
////////////////////////////////////////////////////////////
Font& operator=(const Font& right);
private:
////////////////////////////////////////////////////////////
/// \brief Structure defining a row of glyphs
@ -427,7 +381,7 @@ private:
mutable PageTable m_pages; //!< Table containing the glyphs pages by character size
mutable std::vector<std::uint8_t> m_pixelBuffer; //!< Pixel buffer holding a glyph's pixels before being written to the texture
#ifdef SFML_SYSTEM_ANDROID
std::unique_ptr<priv::ResourceStream> m_stream; //!< Asset file streamer (if loaded from file)
std::shared_ptr<priv::ResourceStream> m_stream; //!< Asset file streamer (if loaded from file)
#endif
};

View File

@ -123,34 +123,6 @@ struct Font::FontHandles
};
////////////////////////////////////////////////////////////
Font::Font() = default;
////////////////////////////////////////////////////////////
// NOLINTNEXTLINE(modernize-use-equals-default)
Font::Font(const Font& copy) :
m_fontHandles(copy.m_fontHandles),
m_isSmooth(copy.m_isSmooth),
m_info(copy.m_info),
m_pages(copy.m_pages),
m_pixelBuffer(copy.m_pixelBuffer)
{
}
////////////////////////////////////////////////////////////
Font::~Font() = default;
////////////////////////////////////////////////////////////
Font::Font(Font&&) noexcept = default;
////////////////////////////////////////////////////////////
Font& Font::operator=(Font&&) noexcept = default;
////////////////////////////////////////////////////////////
bool Font::loadFromFile(const std::filesystem::path& filename)
{
@ -204,7 +176,7 @@ bool Font::loadFromFile(const std::filesystem::path& filename)
#else
m_stream = std::make_unique<priv::ResourceStream>(filename);
m_stream = std::make_shared<priv::ResourceStream>(filename);
return loadFromStream(*m_stream);
#endif
@ -502,25 +474,6 @@ bool Font::isSmooth() const
}
////////////////////////////////////////////////////////////
Font& Font::operator=(const Font& right)
{
Font temp(right);
std::swap(m_fontHandles, temp.m_fontHandles);
std::swap(m_isSmooth, temp.m_isSmooth);
std::swap(m_info, temp.m_info);
std::swap(m_pages, temp.m_pages);
std::swap(m_pixelBuffer, temp.m_pixelBuffer);
#ifdef SFML_SYSTEM_ANDROID
std::swap(m_stream, temp.m_stream);
#endif
return *this;
}
////////////////////////////////////////////////////////////
void Font::cleanup()
{

View File

@ -15,8 +15,8 @@ TEST_CASE("[Graphics] sf::Font", runDisplayTests())
{
STATIC_CHECK(std::is_copy_constructible_v<sf::Font>);
STATIC_CHECK(std::is_copy_assignable_v<sf::Font>);
STATIC_CHECK(std::is_nothrow_move_constructible_v<sf::Font>);
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::Font>);
STATIC_CHECK(std::is_move_constructible_v<sf::Font>);
STATIC_CHECK(std::is_move_assignable_v<sf::Font>);
}
SECTION("Construction")