diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index 2fe2c780f..704dadaa5 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -153,6 +153,26 @@ Containers::Optional AbstractFont::doDataFontCount(Containers::Arra return 1; } +#ifdef MAGNUM_BUILD_DEPRECATED +/* On deprecated builds, doOpenData() / doOpenFile() returns the Properties + instead of being returned through doProperties(). For compatibility we save + contents of the returned struct to the _size etc. members and default + implementation of this function then returns them back. */ +/** @todo remove this once deprecated doOpenData() / doOpenFile() is gone */ +AbstractFont::Properties AbstractFont::doProperties() { + /* If a plugin never implements doProperties(), and doesn't use the + deprecated doOpenData() / doOpenFile() implementations that return a + Properties struct, the glyph count stays set to the original value, + triggering this assert. If it implements doProperties(), this function + never gets called, if it uses the deprecated doOpenData() / doOpenFile() + the value gets overwritten to something else. */ + CORRADE_ASSERT(_glyphCount != ~UnsignedInt{}, + "Text::AbstractFont: doProperties() not implemented", {}); + + return {_size, _ascent, _descent, _lineHeight, _glyphCount}; +} +#endif + bool AbstractFont::openData(const Containers::ArrayView data, const Float size, const UnsignedInt fontId) { CORRADE_ASSERT(features() & FontFeature::OpenData, "Text::AbstractFont::openData(): feature not supported", false); @@ -161,11 +181,17 @@ bool AbstractFont::openData(const Containers::ArrayView data, const the check doesn't be done on the plugin side) because for some file formats it could be valid (MagnumFont in particular). */ close(); - const Properties properties = doOpenData(Containers::arrayCast(data), size, fontId); - - /* If opening succeeded, save the returned values. If not, the values were - set to their default values by close() already. */ + doOpenData(Containers::arrayCast(data), size, fontId); + + /* If opening succeeded, cache reported font properties. If not, the values + were reset to default-constructed values by close(). (OTOH, on + deprecated builds the properties are saved to the _size etc. members + from the deprecated doOpenData() return value, and if doProperties() + isn't implemented, it returns the contents of _size etc. thus there the + following is effectively a no-op, assigning values that are already + there.) */ if(isOpened()) { + const Properties properties = doProperties(); _size = properties.size; _ascent = properties.ascent; _descent = properties.descent; @@ -177,9 +203,9 @@ bool AbstractFont::openData(const Containers::ArrayView data, const return false; } -auto AbstractFont::doOpenData(const Containers::ArrayView data, const Float size, const UnsignedInt fontId) -> Properties { +void AbstractFont::doOpenData(const Containers::ArrayView data, const Float size, const UnsignedInt fontId) { #ifndef MAGNUM_BUILD_DEPRECATED - CORRADE_ASSERT_UNREACHABLE("Text::AbstractFont::openData(): feature advertised but not implemented", {}); + CORRADE_ASSERT_UNREACHABLE("Text::AbstractFont::openData(): feature advertised but not implemented", ); static_cast(data); static_cast(size); static_cast(fontId); @@ -189,12 +215,20 @@ auto AbstractFont::doOpenData(const Containers::ArrayView data, cons otherwise. */ if(fontId != 0) { Error() << "Text::AbstractFont::openData(): cannot open font at index" << fontId; - return {}; + return; } + /* The deprecated overload returns the properties instead of exposing them + through doProperties(). Save them to the _size etc. members, the default + doProperties() implementation then returns those back. */ CORRADE_IGNORE_DEPRECATED_PUSH - return doOpenData(data, size); + const Properties properties = doOpenData(data, size); CORRADE_IGNORE_DEPRECATED_POP + _size = properties.size; + _ascent = properties.ascent; + _descent = properties.descent; + _lineHeight = properties.lineHeight; + _glyphCount = properties.glyphCount; #endif } @@ -286,7 +320,6 @@ Containers::Optional AbstractFont::doFileFontCount(const Containers bool AbstractFont::openFile(const Containers::StringView filename, const Float size, const UnsignedInt fontId) { close(); - Properties properties; /* If file loading callbacks are not set or the font implementation supports handling them directly, call into the implementation */ @@ -297,13 +330,22 @@ bool AbstractFont::openFile(const Containers::StringView filename, const Float s doesn't implement the deprecated doOpenFile(), it delegates back to the new doOpenFile() implementation. */ if(fontId == 0) { + /* The deprecated overload returns the properties instead of + exposing them through doProperties(). Save them to the _size + etc. members, the default doProperties() implementation then + returns those back. */ CORRADE_IGNORE_DEPRECATED_PUSH - properties = doOpenFile(filename, size); + const Properties properties = doOpenFile(filename, size); CORRADE_IGNORE_DEPRECATED_POP + _size = properties.size; + _ascent = properties.ascent; + _descent = properties.descent; + _lineHeight = properties.lineHeight; + _glyphCount = properties.glyphCount; } else #endif { - properties = doOpenFile(filename, size, fontId); + doOpenFile(filename, size, fontId); } /* Otherwise, if loading from data is supported, use the callback and pass @@ -326,15 +368,21 @@ bool AbstractFont::openFile(const Containers::StringView filename, const Float s return isOpened(); } - properties = doOpenData(*data, size, fontId); + doOpenData(*data, size, fontId); _fileCallback(filename, InputFileCallbackPolicy::Close, _fileCallbackUserData); /* Shouldn't get here, the assert is fired already in setFileCallback() */ } else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - /* If opening succeeded, save the returned values. If not, the values were - set to their default values by close() already. */ + /* If opening succeeded, cache reported font properties. If not, the values + were reset to default-constructed values by close(). (OTOH, on + deprecated builds the properties are saved to the _size etc. members + from the deprecated doOpenData() return value, and if doProperties() + isn't implemented, it returns the contents of _size etc. thus there the + following is effectively a no-op, assigning values that are already + there.) */ if(isOpened()) { + const Properties properties = doProperties(); _size = properties.size; _ascent = properties.ascent; _descent = properties.descent; @@ -346,7 +394,7 @@ bool AbstractFont::openFile(const Containers::StringView filename, const Float s return false; } -auto AbstractFont::doOpenFile(const Containers::StringView filename, const Float size, const UnsignedInt fontId) -> Properties { +void AbstractFont::doOpenFile(const Containers::StringView filename, const Float size, const UnsignedInt fontId) { #ifdef MAGNUM_BUILD_DEPRECATED /* If this function is not implemented and opening data isn't supported either, assume the plugin implements only the deprecated doOpenFile() @@ -356,13 +404,12 @@ auto AbstractFont::doOpenFile(const Containers::StringView filename, const Float API or not. */ if(!(features() & FontFeature::OpenData) && fontId != 0) { Error() << "Text::AbstractFont::openFile(): cannot open font at index" << fontId; - return {}; + return; } #endif - CORRADE_ASSERT(features() & FontFeature::OpenData, "Text::AbstractFont::openFile(): not implemented", {}); - - Properties properties; + CORRADE_ASSERT(features() & FontFeature::OpenData, + "Text::AbstractFont::openFile(): not implemented", ); /* If callbacks are set, use them. This is the same implementation as in openFile(), see the comment there for details. */ @@ -370,10 +417,10 @@ auto AbstractFont::doOpenFile(const Containers::StringView filename, const Float const Containers::Optional> data = _fileCallback(filename, InputFileCallbackPolicy::LoadTemporary, _fileCallbackUserData); if(!data) { Error() << "Text::AbstractFont::openFile(): cannot open file" << filename; - return {}; + return; } - properties = doOpenData(*data, size, fontId); + doOpenData(*data, size, fontId); _fileCallback(filename, InputFileCallbackPolicy::Close, _fileCallbackUserData); /* Otherwise open the file directly */ @@ -381,13 +428,11 @@ auto AbstractFont::doOpenFile(const Containers::StringView filename, const Float const Containers::Optional> data = Utility::Path::read(filename); if(!data) { Error() << "Text::AbstractFont::openFile(): cannot open file" << filename; - return {}; + return; } - properties = doOpenData(*data, size, fontId); + doOpenData(*data, size, fontId); } - - return properties; } #ifdef MAGNUM_BUILD_DEPRECATED @@ -400,7 +445,17 @@ auto AbstractFont::doOpenFile(const Containers::StringView filename, const Float a plugin implements the new doOpenFile(), that implementation gets called from here for fontId 0, and from openFile() for all other font IDs. */ - return doOpenFile(filename, size, 0); + doOpenFile(filename, size, 0); + + /* If opening suceeded, return the properties that the implementation + exposes (or, if the above resulted in deprecated doOpenData() being + called, properties that got saved from its return value) */ + if(isOpened()) + return doProperties(); + + /* Otherwise return default-constructed properties, as doProperties() are + meant to be called only if a file is opened */ + return {}; } #endif diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index 8e369bd2f..a0a18f907 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -725,7 +725,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { /** * @brief Font properties * - * Returned from @ref doOpenFile(), @ref doOpenData(). + * Returned from @ref doProperties(). */ struct Properties { #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 @@ -787,36 +787,40 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { * @brief Implementation for @ref openFile() * @m_since_latest * - * If @ref doIsOpened() returns @cpp true @ce after calling this - * function, it's assumed that opening was successful and the - * @ref Properties are expected to contain valid values. If - * @ref doIsOpened() returns @cpp false @ce, the returned values are - * ignored. If @ref FontFeature::OpenData is supported, default - * implementation opens the file and calls @ref doOpenData() with its - * contents. It is allowed to call this function from your - * @ref doOpenFile() implementation --- in particular, this - * implementation will also correctly handle callbacks set through - * @ref setFileCallback(). + * If the operation was successful, @ref doIsOpened() should return + * @cpp true @ce after calling this function, @cpp false @ce otherwise. + * + * If @ref FontFeature::OpenData is supported, default implementation + * opens the file and calls @ref doOpenData() with its contents. It is + * allowed to call this function from your @ref doOpenFile() + * implementation --- in particular, this implementation will also + * correctly handle callbacks set through @ref setFileCallback(). * * This function is not called when file callbacks are set through * @ref setFileCallback() and @ref FontFeature::FileCallback is not * supported --- instead, file is loaded though the callback and data * passed through to @ref doOpenData(). */ - virtual Properties doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId); + virtual void doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId); #ifdef MAGNUM_BUILD_DEPRECATED /** * @brief Implementation for @ref openFile() * @m_deprecated_since_latest Implement @ref doOpenFile(Containers::StringView, Float, UnsignedInt) - * instead. + * and @ref doProperties() instead. + * + * If @ref doIsOpened() returns @cpp true @ce after calling this + * function, it's assumed that opening was successful and the + * @ref Properties are expected to contain valid values. If + * @ref doIsOpened() returns @cpp false @ce, the returned values are + * ignored. */ /* MSVC warns when overriding such methods and there's no way to suppress that warning, making the RT build (which treats deprecation warnings as errors) fail and other builds extremely noisy. So disabling those on MSVC. */ #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) - CORRADE_DEPRECATED("implement doOpenFile(Containers::StringView, Float, UnsignedInt) instead") + CORRADE_DEPRECATED("implement doOpenFile(Containers::StringView, Float, UnsignedInt) and doProperties() instead") #endif virtual Properties doOpenFile(Containers::StringView filename, Float size); #endif @@ -853,26 +857,29 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { * @brief Implementation for @ref openData() * @m_since_latest * - * If @ref doIsOpened() returns @cpp true @ce after calling this - * function, it's assumed that opening was successful and the - * @ref Properties are expected to contain valid values. If - * @ref doIsOpened() returns @cpp false @ce, the returned values are - * ignored. + * If the operation was successful, @ref doIsOpened() should return + * @cpp true @ce after calling this function, @cpp false @ce otherwise. */ - virtual Properties doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId); + virtual void doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId); #ifdef MAGNUM_BUILD_DEPRECATED /** * @brief Implementation for @ref openData() * @m_deprecated_since_latest Implement @ref doOpenData(Containers::ArrayView, Float, UnsignedInt) - * instead. + * and @ref doProperties() instead. + * + * If @ref doIsOpened() returns @cpp true @ce after calling this + * function, it's assumed that opening was successful and the + * @ref Properties are expected to contain valid values. If + * @ref doIsOpened() returns @cpp false @ce, the returned values are + * ignored. */ /* MSVC warns when overriding such methods and there's no way to suppress that warning, making the RT build (which treats deprecation warnings as errors) fail and other builds extremely noisy. So disabling those on MSVC. */ #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) - CORRADE_DEPRECATED("implement doOpenData(Containers::ArrayView, Float, UnsignedInt) instead") + CORRADE_DEPRECATED("implement doOpenData(Containers::ArrayView, Float, UnsignedInt) and doProperties() instead") #endif virtual Properties doOpenData(Containers::ArrayView data, Float size); #endif @@ -880,6 +887,25 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { /** @brief Implementation for @ref close() */ virtual void doClose() = 0; + /** + * @brief Implementation for @ref size(), @ref ascent(), @ref descent(), @ref lineHeight() and @ref glyphCount() + * @m_since_latest + * + * This function gets called internally from @ref openFile() and + * @ref openData() after a font is successfully opened, caching the + * returned @ref Properties to make them subsequently accessible + * through the public APIs. The function is guaranteed to be called + * only if @ref isOpened() returns @cpp true @ce. + */ + virtual Properties doProperties() + #ifndef MAGNUM_BUILD_DEPRECATED + /* On deprecated builds the properties may be taken from + doOpenData() / doOpenFile() return values instead of forcing + this function to be implemented */ + = 0 + #endif + ; + /** * @brief Implementation for @ref glyphIdsInto() * @m_since_latest @@ -956,7 +982,13 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { #endif Float _size{}, _ascent{}, _descent{}, _lineHeight{}; - UnsignedInt _glyphCount{}; + UnsignedInt _glyphCount{ + #ifdef MAGNUM_BUILD_DEPRECATED + /* Kill switch for detecting if doProperties() is implemented, see + its implementation for details */ + ~UnsignedInt{} + #endif + }; }; #ifdef MAGNUM_BUILD_DEPRECATED diff --git a/src/Magnum/Text/Test/AbstractFontTest.cpp b/src/Magnum/Text/Test/AbstractFontTest.cpp index fb474d7d5..03bad0da6 100644 --- a/src/Magnum/Text/Test/AbstractFontTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontTest.cpp @@ -109,6 +109,9 @@ struct AbstractFontTest: TestSuite::Tester { void openFileNotImplemented(); void openDataNotSupported(); void openDataNotImplemented(); + #ifdef MAGNUM_BUILD_DEPRECATED + void propertiesNotImplemented(); + #endif void setFileCallback(); void setFileCallbackTemplate(); @@ -210,6 +213,19 @@ const struct { {"with a font opened", true} }; +#ifdef MAGNUM_BUILD_DEPRECATED +const struct { + const char* name; + bool openFile; + UnsignedInt fontId; +} PropertiesNotImplementedData[]{ + {"open data", false, 0}, + {"open data, non-zero font ID", false, 1}, + {"open file", true, 0}, + {"open file, non-zero font ID", true, 1}, +}; +#endif + AbstractFontTest::AbstractFontTest() { addTests({&AbstractFontTest::debugFeature, &AbstractFontTest::debugFeaturePacked, @@ -290,6 +306,11 @@ AbstractFontTest::AbstractFontTest() { &AbstractFontTest::openDataNotImplemented}, Containers::arraySize(OpenData)); + #ifdef MAGNUM_BUILD_DEPRECATED + addInstancedTests({&AbstractFontTest::propertiesNotImplemented}, + Containers::arraySize(PropertiesNotImplementedData)); + #endif + addTests({&AbstractFontTest::setFileCallback, &AbstractFontTest::setFileCallbackTemplate, &AbstractFontTest::setFileCallbackTemplateNull, @@ -428,6 +449,7 @@ void AbstractFontTest::construct() { CORRADE_FAIL("This should not be called"); } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -460,11 +482,11 @@ void AbstractFontTest::dataFontCount() { return 37; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; - return {}; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -502,11 +524,11 @@ void AbstractFontTest::dataFontCountFailed() { return {}; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; - return {}; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -542,6 +564,7 @@ void AbstractFontTest::dataFontCountNotImplemented() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -568,11 +591,11 @@ void AbstractFontTest::fileFontCount() { return 37; } - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { _opened = true; - return {}; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -609,11 +632,11 @@ void AbstractFontTest::fileFontCountFailed() { return {}; } - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { _opened = true; - return {}; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -649,6 +672,7 @@ void AbstractFontTest::fileFontCountNotImplemented() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -678,11 +702,11 @@ void AbstractFontTest::fileFontCountAsData() { return 37; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; - return {}; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -719,11 +743,11 @@ void AbstractFontTest::fileFontCountAsDataNotFound() { return {}; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; - return {}; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -768,11 +792,11 @@ void AbstractFontTest::fileFontCountAsDataFailed() { return {}; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; - return {}; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -808,6 +832,7 @@ void AbstractFontTest::fileFontCountAsDataNotImplemented() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -835,6 +860,7 @@ void AbstractFontTest::fontCountInvalid() { return 0; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -860,6 +886,7 @@ void AbstractFontTest::dataFontCountNotSupported() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -884,13 +911,17 @@ void AbstractFontTest::openData() { _opened = false; } - Properties doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId) override { + void doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId) override { CORRADE_COMPARE_AS(data, Containers::arrayView({'\xa5'}), TestSuite::Compare::Container); + CORRADE_COMPARE(size, 13.0f); CORRADE_COMPARE(fontId, expectedFontId); _opened = true; - return {size, 1.0f, 2.0f, 3.0f, 15}; + } + + Properties doProperties() override { + return {31.0f, 1.0f, 2.0f, 3.0f, 15}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} @@ -913,7 +944,7 @@ void AbstractFontTest::openData() { supply a constant instead */ CORRADE_VERIFY(font.openData(a5, 13.0f, data.fontId)); CORRADE_VERIFY(font.isOpened()); - CORRADE_COMPARE(font.size(), 13.0f); + CORRADE_COMPARE(font.size(), 31.0f); CORRADE_COMPARE(font.ascent(), 1.0f); CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f); @@ -1009,11 +1040,14 @@ void AbstractFontTest::openDataFailed() { bool doIsOpened() const override { return false; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { called = true; - return {}; } + Properties doProperties() override { + CORRADE_FAIL("This should not be called"); + return {}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1080,11 +1114,15 @@ void AbstractFontTest::openFile() { _opened = false; } - Properties doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { + void doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { CORRADE_COMPARE(filename, "hello.ttf"); + CORRADE_COMPARE(size, 13.0f); CORRADE_COMPARE(fontId, expectedFontId); _opened = true; - return {size, 1.0f, 2.0f, 3.0f, 15}; + } + + Properties doProperties() override { + return {31.0f, 1.0f, 2.0f, 3.0f, 15}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} @@ -1106,7 +1144,7 @@ void AbstractFontTest::openFile() { supply a constant instead */ CORRADE_VERIFY(font.openFile("hello.ttf", 13.0f, data.fontId)); CORRADE_VERIFY(font.isOpened()); - CORRADE_COMPARE(font.size(), 13.0f); + CORRADE_COMPARE(font.size(), 31.0f); CORRADE_COMPARE(font.ascent(), 1.0f); CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f); @@ -1198,11 +1236,14 @@ void AbstractFontTest::openFileFailed() { bool doIsOpened() const override { return false; } void doClose() override {} - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { called = true; - return {}; } + Properties doProperties() override { + CORRADE_FAIL("This should not be called"); + return {}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1266,15 +1307,18 @@ void AbstractFontTest::openFileAsData() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId) override { + void doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId) override { CORRADE_COMPARE_AS(data, Containers::arrayView({'\xa5'}), TestSuite::Compare::Container); + CORRADE_COMPARE(size, 13.0f); CORRADE_COMPARE(fontId, expectedFontId); _opened = true; - return {size, 1.0f, 2.0f, 3.0f, 15}; } + Properties doProperties() override { + return {31.0f, 1.0f, 2.0f, 3.0f, 15}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1295,7 +1339,7 @@ void AbstractFontTest::openFileAsData() { supply a constant instead */ CORRADE_VERIFY(font.openFile(Utility::Path::join(TEXT_TEST_DIR, "data.bin"), 13.0f, data.fontId)); CORRADE_VERIFY(font.isOpened()); - CORRADE_COMPARE(font.size(), 13.0f); + CORRADE_COMPARE(font.size(), 31.0f); CORRADE_COMPARE(font.ascent(), 1.0f); CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f); @@ -1311,11 +1355,14 @@ void AbstractFontTest::openFileAsDataNotFound() { bool doIsOpened() const override { return false; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } + Properties doProperties() override { + CORRADE_FAIL("This should not be called"); + return {}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1419,11 +1466,14 @@ void AbstractFontTest::openFileAsDataFailed() { bool doIsOpened() const override { return false; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { called = true; - return {}; } + Properties doProperties() override { + CORRADE_FAIL("This should not be called"); + return {}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1490,6 +1540,7 @@ void AbstractFontTest::openFileNotImplemented() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1528,6 +1579,7 @@ void AbstractFontTest::openDataNotSupported() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1554,6 +1606,7 @@ void AbstractFontTest::openDataNotImplemented() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1580,6 +1633,49 @@ void AbstractFontTest::openDataNotImplemented() { #endif } +#ifdef MAGNUM_BUILD_DEPRECATED +void AbstractFontTest::propertiesNotImplemented() { + auto&& data = PropertiesNotImplementedData[testCaseInstanceId()]; + setTestCaseDescription(data.name); + + CORRADE_SKIP_IF_NO_ASSERT(); + + /* On non-deprecated builds doProperties() is pure virtual, which forces + its implementation at compile time. This assertion is to tell the same + to implementers on builds with deprecated features enabled, although + only at runtime. */ + + struct: AbstractFont { + FontFeatures doFeatures() const override { return FontFeature::OpenData; } + bool doIsOpened() const override { return _opened; } + void doClose() override {} + + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { + _opened = true; + } + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + _opened = true; + } + + void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} + Vector2 doGlyphSize(UnsignedInt) override { return {}; } + Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } + Containers::Pointer doCreateShaper() override { return {}; } + + private: + bool _opened = false; + } font; + + Containers::String out; + Error redirectError{&out}; + if(data.openFile) + font.openFile({}, 1.0f, data.fontId); + else + font.openData({}, 1.0f, data.fontId); + CORRADE_COMPARE(out, "Text::AbstractFont: doProperties() not implemented\n"); +} +#endif + void AbstractFontTest::setFileCallback() { struct: AbstractFont { FontFeatures doFeatures() const override { return FontFeature::OpenData|FontFeature::FileCallback; } @@ -1589,6 +1685,7 @@ void AbstractFontTest::setFileCallback() { *static_cast(userData) = 1337; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1614,6 +1711,7 @@ void AbstractFontTest::setFileCallbackTemplate() { called = true; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1647,6 +1745,7 @@ void AbstractFontTest::setFileCallbackTemplateNull() { called = true; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1671,6 +1770,7 @@ void AbstractFontTest::setFileCallbackTemplateConst() { called = true; } + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1697,6 +1797,7 @@ void AbstractFontTest::setFileCallbackFileOpened() { bool doIsOpened() const override { return true; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1717,6 +1818,7 @@ void AbstractFontTest::setFileCallbackNotImplemented() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1741,6 +1843,7 @@ void AbstractFontTest::setFileCallbackNotSupported() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1779,21 +1882,23 @@ void AbstractFontTest::setFileCallbackOpenFileDirectly() { return {}; } - Properties doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { + void doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { /* Called because FileCallback is supported */ CORRADE_COMPARE(filename, "file.dat"); + CORRADE_COMPARE(size, 42.0f); CORRADE_COMPARE(fontId, expectedFontId); CORRADE_VERIFY(fileCallback()); CORRADE_VERIFY(fileCallbackUserData()); _opened = true; - return {size, 1.0f, 2.0f, 3.0f, 15}; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } + Properties doProperties() override { + return {24.0f, 1.0f, 2.0f, 3.0f, 15}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -1822,7 +1927,7 @@ void AbstractFontTest::setFileCallbackOpenFileDirectly() { supply a constant instead */ CORRADE_VERIFY(font.openFile("file.dat", 42.0f, data.fontId)); CORRADE_VERIFY(font.isOpened()); - CORRADE_COMPARE(font.size(), 42.0f); + CORRADE_COMPARE(font.size(), 24.0f); CORRADE_COMPARE(font.ascent(), 1.0f); CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f); @@ -1849,9 +1954,8 @@ void AbstractFontTest::setFileCallbackOpenFileDirectlyDeprecated() { return {size, 1.0f, 2.0f, 3.0f, 15}; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } Properties doOpenData(Containers::ArrayView, Float) override { CORRADE_FAIL("This should not be called"); @@ -1959,16 +2063,18 @@ void AbstractFontTest::setFileCallbackOpenFileDirectlyFailed() { return {}; } - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { openCalled = true; - return {}; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } + Properties doProperties() override { + CORRADE_FAIL("This should not be called"); + return {}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -2016,9 +2122,8 @@ void AbstractFontTest::setFileCallbackOpenFileDirectlyFailedDeprecated() { return {}; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } Properties doOpenData(Containers::ArrayView, Float) override { CORRADE_FAIL("This should not be called"); @@ -2072,24 +2177,28 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementation() { return 37; } - Properties doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { + void doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { CORRADE_COMPARE(filename, "file.dat"); + CORRADE_COMPARE(size, 42.0f); CORRADE_COMPARE(fontId, expectedFontId); CORRADE_VERIFY(fileCallback()); CORRADE_VERIFY(fileCallbackUserData()); openCalled = true; - return AbstractFont::doOpenFile(filename, size, fontId); + AbstractFont::doOpenFile(filename, size, fontId); } - Properties doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId) override { + void doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId) override { CORRADE_COMPARE_AS(data, Containers::arrayView({'\xb0'}), TestSuite::Compare::Container); + CORRADE_COMPARE(size, 42.0f); CORRADE_COMPARE(fontId, expectedFontId); _opened = true; - return {size, 1.0f, 2.0f, 3.0f, 15}; } + Properties doProperties() override { + return {24.0f, 1.0f, 2.0f, 3.0f, 15}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -2141,7 +2250,7 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementation() { CORRADE_VERIFY(font.openCalled); CORRADE_COMPARE(state.loaded, 2); CORRADE_COMPARE(state.closed, 2); - CORRADE_COMPARE(font.size(), 42.0f); + CORRADE_COMPARE(font.size(), 24.0f); CORRADE_COMPARE(font.ascent(), 1.0f); CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f); @@ -2244,16 +2353,19 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementationNotFound( return 37; } - Properties doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { + void doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { openCalled = true; - return AbstractFont::doOpenFile(filename, size, fontId); + AbstractFont::doOpenFile(filename, size, fontId); } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } + Properties doProperties() override { + CORRADE_FAIL("This should not be called"); + return {}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -2312,16 +2424,19 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementationFailed() return {}; } - Properties doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { + void doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { openFileCalled = true; - return AbstractFont::doOpenFile(filename, size, fontId); + AbstractFont::doOpenFile(filename, size, fontId); } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { openDataCalled = true; - return {}; } + Properties doProperties() override { + CORRADE_FAIL("This should not be called"); + return {}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -2464,18 +2579,21 @@ void AbstractFontTest::setFileCallbackOpenFileAsData() { return 37; } - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } - Properties doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId) override { + void doOpenData(Containers::ArrayView data, Float size, UnsignedInt fontId) override { CORRADE_COMPARE_AS(data, Containers::arrayView({'\xb0'}), TestSuite::Compare::Container); + CORRADE_COMPARE(size, 13.0f); CORRADE_COMPARE(fontId, expectedFontId); _opened = true; - return {size, 1.0f, 2.0f, 3.0f, 15}; + } + + Properties doProperties() override { + return {31.0f, 1.0f, 2.0f, 3.0f, 15}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} @@ -2523,7 +2641,7 @@ void AbstractFontTest::setFileCallbackOpenFileAsData() { CORRADE_VERIFY(font.isOpened()); CORRADE_COMPARE(state.loaded, 2); CORRADE_COMPARE(state.closed, 2); - CORRADE_COMPARE(font.size(), 13.0f); + CORRADE_COMPARE(font.size(), 31.0f); CORRADE_COMPARE(font.ascent(), 1.0f); CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f); @@ -2541,9 +2659,8 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataDeprecated() { bool doIsOpened() const override { return _opened; } void doClose() override { _opened = false; } - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } Properties doOpenFile(Containers::StringView, Float) override { CORRADE_FAIL("This should not be called"); @@ -2609,9 +2726,8 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataDeprecatedNonZeroFontId() { bool doIsOpened() const override { return _opened; } void doClose() override { _opened = false; } - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } Properties doOpenFile(Containers::StringView, Float) override { CORRADE_FAIL("This should not be called"); @@ -2680,16 +2796,18 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataNotFound() { return {}; } - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } + Properties doProperties() override { + CORRADE_FAIL("This should not be called"); + return {}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -2741,16 +2859,18 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataFailed() { return {}; } - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { openCalled = true; - return {}; } + Properties doProperties() override { + CORRADE_FAIL("This should not be called"); + return {}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -2812,9 +2932,8 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataFailedDeprecated() { bool doIsOpened() const override { return false; } void doClose() override {} - Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { + void doOpenFile(Containers::StringView, Float, UnsignedInt) override { CORRADE_FAIL("This should not be called"); - return {}; } Properties doOpenFile(Containers::StringView, Float) override { CORRADE_FAIL("This should not be called"); @@ -2871,11 +2990,13 @@ void AbstractFontTest::properties() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float size, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; - return {size, 1.0f, 2.0f, 3.0f, 15}; } + Properties doProperties() override { + return {13.0f, 1.0f, 2.0f, 3.0f, 15}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -2884,7 +3005,7 @@ void AbstractFontTest::properties() { bool _opened = false; } font; - CORRADE_VERIFY(font.openData(nullptr, 13.0f)); + CORRADE_VERIFY(font.openData(nullptr, 0.0f)); CORRADE_VERIFY(font.isOpened()); CORRADE_COMPARE(font.size(), 13.0f); CORRADE_COMPARE(font.ascent(), 1.0f); @@ -2901,6 +3022,7 @@ void AbstractFontTest::propertiesNoFont() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -2930,8 +3052,11 @@ void AbstractFontTest::glyphId() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 1280}; } @@ -2970,6 +3095,7 @@ void AbstractFontTest::glyphIdNoFont() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -2994,6 +3120,7 @@ void AbstractFontTest::glyphIdInvalidSize() { bool doIsOpened() const override { return true; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3019,11 +3146,13 @@ void AbstractFontTest::glyphIdOutOfRange() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; - return {0.0f, 0.0f, 0.0f, 0.0f, 4}; } + Properties doProperties() override { + return {0.0f, 0.0f, 0.0f, 0.0f, 4}; + } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D& glyphs) override { for(std::size_t i = 0; i != glyphs.size(); ++i) glyphs[i] = i; @@ -3058,8 +3187,11 @@ void AbstractFontTest::glyphName() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 4}; } @@ -3093,8 +3225,11 @@ void AbstractFontTest::glyphNameNotImplemented() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 4}; } @@ -3122,6 +3257,7 @@ void AbstractFontTest::glyphNameNoFont() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3147,8 +3283,11 @@ void AbstractFontTest::glyphNameOutOfRange() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 4}; } @@ -3180,8 +3319,11 @@ void AbstractFontTest::glyphSizeAdvance() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 98}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} @@ -3206,6 +3348,7 @@ void AbstractFontTest::glyphSizeAdvanceNoFont() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3229,8 +3372,11 @@ void AbstractFontTest::glyphSizeAdvanceOutOfRange() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 3}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} @@ -3268,8 +3414,11 @@ void AbstractFontTest::fillGlyphCache() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 17}; } @@ -3320,8 +3469,11 @@ void AbstractFontTest::fillGlyphCacheOutOfRange() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 16}; } @@ -3357,8 +3509,11 @@ void AbstractFontTest::fillGlyphCacheNotUnique() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 16}; } @@ -3390,8 +3545,11 @@ void AbstractFontTest::fillGlyphCacheFromString() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 17}; } @@ -3458,8 +3616,11 @@ void AbstractFontTest::fillGlyphCacheFailed() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 1}; } @@ -3500,6 +3661,7 @@ void AbstractFontTest::fillGlyphCacheNotSupported() { bool doIsOpened() const override { return true; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D& glyphs) override { /* Set all to 0 to avoid an assert that the IDs are out of range */ for(UnsignedInt& i: glyphs) @@ -3532,8 +3694,11 @@ void AbstractFontTest::fillGlyphCacheNotImplemented() { bool doIsOpened() const override { return _opened; } void doClose() override {} - Properties doOpenData(Containers::ArrayView, Float, UnsignedInt) override { + void doOpenData(Containers::ArrayView, Float, UnsignedInt) override { _opened = true; + } + + Properties doProperties() override { return {0.0f, 0.0f, 0.0f, 0.0f, 1}; } @@ -3569,6 +3734,7 @@ void AbstractFontTest::fillGlyphCacheNoFont() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3595,6 +3761,7 @@ void AbstractFontTest::fillGlyphCacheInvalidUtf8() { bool doIsOpened() const override { return true; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3614,6 +3781,7 @@ void AbstractFontTest::createGlyphCache() { bool doIsOpened() const override { return true; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3638,6 +3806,7 @@ void AbstractFontTest::createGlyphCacheNotSupported() { bool doIsOpened() const override { return true; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3658,6 +3827,7 @@ void AbstractFontTest::createGlyphCacheNotImplemented() { bool doIsOpened() const override { return true; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3678,6 +3848,7 @@ void AbstractFontTest::createGlyphCacheNoFont() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3708,6 +3879,7 @@ void AbstractFontTest::createShaper() { bool doIsOpened() const override { return true; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3726,6 +3898,7 @@ void AbstractFontTest::createShaperNoFont() { bool doIsOpened() const override { return false; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } @@ -3746,6 +3919,7 @@ void AbstractFontTest::createShaperNullptr() { bool doIsOpened() const override { return true; } void doClose() override {} + Properties doProperties() override { return {}; } void doGlyphIdsInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) override {} Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }