diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp index e04bc40d5..efee48460 100644 --- a/include/SFML/Graphics/Font.hpp +++ b/include/SFML/Graphics/Font.hpp @@ -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 m_pixelBuffer; //!< Pixel buffer holding a glyph's pixels before being written to the texture #ifdef SFML_SYSTEM_ANDROID - std::unique_ptr m_stream; //!< Asset file streamer (if loaded from file) + std::shared_ptr m_stream; //!< Asset file streamer (if loaded from file) #endif }; diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 604b96cd6..daafa6720 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -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(filename); + m_stream = std::make_shared(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() { diff --git a/test/Graphics/Font.test.cpp b/test/Graphics/Font.test.cpp index b6a4380d4..b7bd1a207 100644 --- a/test/Graphics/Font.test.cpp +++ b/test/Graphics/Font.test.cpp @@ -15,8 +15,8 @@ TEST_CASE("[Graphics] sf::Font", runDisplayTests()) { STATIC_CHECK(std::is_copy_constructible_v); STATIC_CHECK(std::is_copy_assignable_v); - STATIC_CHECK(std::is_nothrow_move_constructible_v); - STATIC_CHECK(std::is_nothrow_move_assignable_v); + STATIC_CHECK(std::is_move_constructible_v); + STATIC_CHECK(std::is_move_assignable_v); } SECTION("Construction")