From 5ace409371866ce0c6e1021882577da203a31312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 20 Sep 2023 13:51:38 +0200 Subject: [PATCH] Text: removed AbstractFont APIs deprecated in 2019.10. A std::vector of std::pairs of std::strings, ugh! --- doc/changelog.dox | 5 ++ src/Magnum/Text/AbstractFont.cpp | 17 ----- src/Magnum/Text/AbstractFont.h | 25 ------- src/Magnum/Text/Test/AbstractFontTest.cpp | 81 ----------------------- 4 files changed, 5 insertions(+), 123 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index e70fd33da..e07dd0b01 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -1426,6 +1426,11 @@ See also: @ref Math::Color4::fromHsv() overloads taking separate hue, saturation and value arguments. Use the @ref Math::ColorHsv struct instead. - @cpp Math::swizzle() @ce, use @ref Math::gather() instead + - @cpp Text::FontFeature::MultiFile @ce, + @cpp Text::AbstractFont::openData() @ce taking a vector of pairs, and + @cpp openSingleData() @ce, use @ref Text::AbstractFont::openData() and + @relativeref{Text::AbstractFont,setFileCallback()} for opening + multi-file fonts instead - All includes of @ref Corrade/Containers/PointerStl.h and @ref Corrade/Containers/ArrayViewStl.h that were added in 2019.01 for preserving backwards compatibility after the move from @ref std::unique_ptr diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index 6c8f4c7f0..3bf17fc61 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -116,23 +116,6 @@ auto AbstractFont::doOpenData(Containers::ArrayView, Float) -> Metri CORRADE_ASSERT_UNREACHABLE("Text::AbstractFont::openData(): feature advertised but not implemented", {}); } -#ifdef MAGNUM_BUILD_DEPRECATED -bool AbstractFont::openData(const std::vector>>& data, const Float size) { - close(); - - setFileCallback([](const std::string& file, InputFileCallbackPolicy, const std::vector>>& data) -> Containers::Optional> { - for(auto&& i: data) if(i.first == file) return i.second; - return {}; - }, data); - - return !data.empty() && openData(data.front().second, size); -} - -bool AbstractFont::openSingleData(const Containers::ArrayView data, const Float size) { - return openData(data, size); -} -#endif - bool AbstractFont::openFile(const std::string& filename, const Float size) { close(); Metrics metrics; diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index 01ca370e2..0f9a66c09 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -30,7 +30,6 @@ */ #include -#include #include #include @@ -62,16 +61,6 @@ enum class FontFeature: UnsignedByte { */ FileCallback = 1 << 1, - #ifdef MAGNUM_BUILD_DEPRECATED - /** - * The format is multi-file, thus @ref AbstractFont::openSingleData() - * convenience function cannot be used. - * @m_deprecated_since{2019,10} Obsolete, use file callbacks - * instead. - */ - MultiFile CORRADE_DEPRECATED_ENUM("obsolete, use file callbacks instead") = FileCallback, - #endif - /** * The font contains a prepared glyph cache. * @see @ref AbstractFont::fillGlyphCache(), @@ -370,20 +359,6 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { */ bool openData(Containers::ArrayView data, Float size); - #ifdef MAGNUM_BUILD_DEPRECATED - /** @brief @copybrief openData(Containers::ArrayView, Float) - * @m_deprecated_since{2019,10} Use @ref openFile() with - * @ref setFileCallback() for opening multi-file fonts instead. - */ - CORRADE_DEPRECATED("use openFile() with setFileCallback() for opening multi-file fonts instead") bool openData(const std::vector>>& data, Float size); - - /** @brief @copybrief openData(Containers::ArrayView, Float) - * @m_deprecated_since{2019,10} Use @ref openData(Containers::ArrayView, Float) - * instead. - */ - CORRADE_DEPRECATED("use openData(Containers::ArrayView, Float) instead") bool openSingleData(Containers::ArrayView data, Float size); - #endif - /** * @brief Open a file * @param filename Font file diff --git a/src/Magnum/Text/Test/AbstractFontTest.cpp b/src/Magnum/Text/Test/AbstractFontTest.cpp index 94f223073..8e2a72d8d 100644 --- a/src/Magnum/Text/Test/AbstractFontTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontTest.cpp @@ -54,11 +54,6 @@ struct AbstractFontTest: TestSuite::Tester { void openDataNotSupported(); void openDataNotImplemented(); - #ifdef MAGNUM_BUILD_DEPRECATED - void openSingleDataDeprecated(); - void openMultiDataDeprecated(); - #endif - void setFileCallback(); void setFileCallbackTemplate(); void setFileCallbackTemplateNull(); @@ -111,11 +106,6 @@ AbstractFontTest::AbstractFontTest() { &AbstractFontTest::openDataNotSupported, &AbstractFontTest::openDataNotImplemented, - #ifdef MAGNUM_BUILD_DEPRECATED - &AbstractFontTest::openSingleDataDeprecated, - &AbstractFontTest::openMultiDataDeprecated, - #endif - &AbstractFontTest::setFileCallback, &AbstractFontTest::setFileCallbackTemplate, &AbstractFontTest::setFileCallbackTemplateNull, @@ -324,77 +314,6 @@ void AbstractFontTest::openDataNotImplemented() { CORRADE_COMPARE(out.str(), "Text::AbstractFont::openData(): feature advertised but not implemented\n"); } -#ifdef MAGNUM_BUILD_DEPRECATED -void AbstractFontTest::openSingleDataDeprecated() { - struct: AbstractFont { - FontFeatures doFeatures() const override { return FontFeature::OpenData; } - bool doIsOpened() const override { return _opened; } - void doClose() override {} - - Metrics doOpenData(const Containers::ArrayView data, Float size) override { - _opened = (data.size() == 1 && data[0] == '\xa5'); - return {size, 1.0f, 2.0f, 3.0f}; - } - - UnsignedInt doGlyphId(char32_t) override { return {}; } - Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } - Containers::Pointer doLayout(const AbstractGlyphCache&, Float, const std::string&) override { - return nullptr; - } - - bool _opened = false; - } font; - - CORRADE_VERIFY(!font.isOpened()); - const char a5 = '\xa5'; - CORRADE_IGNORE_DEPRECATED_PUSH - font.openSingleData({&a5, 1}, 13.0f); - CORRADE_IGNORE_DEPRECATED_POP - CORRADE_VERIFY(font.isOpened()); - CORRADE_COMPARE(font.size(), 13.0f); - CORRADE_COMPARE(font.ascent(), 1.0f); - CORRADE_COMPARE(font.descent(), 2.0f); - CORRADE_COMPARE(font.lineHeight(), 3.0f); -} - -void AbstractFontTest::openMultiDataDeprecated() { - struct: AbstractFont { - FontFeatures doFeatures() const override { return FontFeature::OpenData; } - bool doIsOpened() const override { return _opened; } - void doClose() override {} - - Metrics doOpenData(const Containers::ArrayView data, Float size) override { - if(!fileCallback()) return {}; - Containers::Optional> dataExt = fileCallback()("data.ext", InputFileCallbackPolicy::LoadPermanent, fileCallbackUserData()); - _opened = (data.size() == 1 && data[0] == '\xa5' && dataExt && - dataExt->size() == 2 && (*dataExt)[1] == '\xee'); - return {size, 1.0f, 2.0f, 3.0f}; - } - - UnsignedInt doGlyphId(char32_t) override { return {}; } - Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } - Containers::Pointer doLayout(const AbstractGlyphCache&, Float, const std::string&) override { - return nullptr; - } - - bool _opened = false; - } font; - - CORRADE_VERIFY(!font.isOpened()); - const char a5 = '\xa5'; - const char ee[] = { '\xff', '\xee' }; - CORRADE_IGNORE_DEPRECATED_PUSH - font.openData({{"data.bin", {&a5, 1}}, - {"data.ext", ee}}, 13.0f); - CORRADE_IGNORE_DEPRECATED_POP - CORRADE_VERIFY(font.isOpened()); - CORRADE_COMPARE(font.size(), 13.0f); - CORRADE_COMPARE(font.ascent(), 1.0f); - CORRADE_COMPARE(font.descent(), 2.0f); - CORRADE_COMPARE(font.lineHeight(), 3.0f); -} -#endif - void AbstractFontTest::setFileCallback() { struct: AbstractFont { FontFeatures doFeatures() const override { return FontFeature::OpenData|FontFeature::FileCallback; }