Browse Source

Text: decouple font property querying from file / data opening.

This will eventually make it possible to create always-open font
implementations, as in those doProperties() can be called on-demand
without requiring a dummy implementation of doOpenFile() / doOpenData()
and doClose() that is there only to fill the Properties struct.

Thanks to the doOpenFile() / doOpenData() signature changing in the
previous commit I can do this in a backwards-compatible way, keeping the
original signature as a deprecated API. Changing just the return value
would be a hard breaking change.

As with previous commit, only AbstractFont tests themselves are adapted
to the changes, not the rest yet, so a non-deprecated build will now
fail.
pull/482/merge
Vladimír Vondruš 1 week ago
parent
commit
53a500bf47
  1. 107
      src/Magnum/Text/AbstractFont.cpp
  2. 78
      src/Magnum/Text/AbstractFont.h
  3. 360
      src/Magnum/Text/Test/AbstractFontTest.cpp

107
src/Magnum/Text/AbstractFont.cpp

@ -153,6 +153,26 @@ Containers::Optional<UnsignedInt> AbstractFont::doDataFontCount(Containers::Arra
return 1; 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<const void> data, const Float size, const UnsignedInt fontId) { bool AbstractFont::openData(const Containers::ArrayView<const void> data, const Float size, const UnsignedInt fontId) {
CORRADE_ASSERT(features() & FontFeature::OpenData, CORRADE_ASSERT(features() & FontFeature::OpenData,
"Text::AbstractFont::openData(): feature not supported", false); "Text::AbstractFont::openData(): feature not supported", false);
@ -161,11 +181,17 @@ bool AbstractFont::openData(const Containers::ArrayView<const void> data, const
the check doesn't be done on the plugin side) because for some file the check doesn't be done on the plugin side) because for some file
formats it could be valid (MagnumFont in particular). */ formats it could be valid (MagnumFont in particular). */
close(); close();
const Properties properties = doOpenData(Containers::arrayCast<const char>(data), size, fontId); doOpenData(Containers::arrayCast<const char>(data), size, fontId);
/* If opening succeeded, save the returned values. If not, the values were /* If opening succeeded, cache reported font properties. If not, the values
set to their default values by close() already. */ 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()) { if(isOpened()) {
const Properties properties = doProperties();
_size = properties.size; _size = properties.size;
_ascent = properties.ascent; _ascent = properties.ascent;
_descent = properties.descent; _descent = properties.descent;
@ -177,9 +203,9 @@ bool AbstractFont::openData(const Containers::ArrayView<const void> data, const
return false; return false;
} }
auto AbstractFont::doOpenData(const Containers::ArrayView<const char> data, const Float size, const UnsignedInt fontId) -> Properties { void AbstractFont::doOpenData(const Containers::ArrayView<const char> data, const Float size, const UnsignedInt fontId) {
#ifndef MAGNUM_BUILD_DEPRECATED #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<void>(data); static_cast<void>(data);
static_cast<void>(size); static_cast<void>(size);
static_cast<void>(fontId); static_cast<void>(fontId);
@ -189,12 +215,20 @@ auto AbstractFont::doOpenData(const Containers::ArrayView<const char> data, cons
otherwise. */ otherwise. */
if(fontId != 0) { if(fontId != 0) {
Error() << "Text::AbstractFont::openData(): cannot open font at index" << fontId; 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 CORRADE_IGNORE_DEPRECATED_PUSH
return doOpenData(data, size); const Properties properties = doOpenData(data, size);
CORRADE_IGNORE_DEPRECATED_POP CORRADE_IGNORE_DEPRECATED_POP
_size = properties.size;
_ascent = properties.ascent;
_descent = properties.descent;
_lineHeight = properties.lineHeight;
_glyphCount = properties.glyphCount;
#endif #endif
} }
@ -286,7 +320,6 @@ Containers::Optional<UnsignedInt> AbstractFont::doFileFontCount(const Containers
bool AbstractFont::openFile(const Containers::StringView filename, const Float size, const UnsignedInt fontId) { bool AbstractFont::openFile(const Containers::StringView filename, const Float size, const UnsignedInt fontId) {
close(); close();
Properties properties;
/* If file loading callbacks are not set or the font implementation /* If file loading callbacks are not set or the font implementation
supports handling them directly, call into the 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 doesn't implement the deprecated doOpenFile(), it delegates back to
the new doOpenFile() implementation. */ the new doOpenFile() implementation. */
if(fontId == 0) { 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 CORRADE_IGNORE_DEPRECATED_PUSH
properties = doOpenFile(filename, size); const Properties properties = doOpenFile(filename, size);
CORRADE_IGNORE_DEPRECATED_POP CORRADE_IGNORE_DEPRECATED_POP
_size = properties.size;
_ascent = properties.ascent;
_descent = properties.descent;
_lineHeight = properties.lineHeight;
_glyphCount = properties.glyphCount;
} else } else
#endif #endif
{ {
properties = doOpenFile(filename, size, fontId); doOpenFile(filename, size, fontId);
} }
/* Otherwise, if loading from data is supported, use the callback and pass /* 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(); return isOpened();
} }
properties = doOpenData(*data, size, fontId); doOpenData(*data, size, fontId);
_fileCallback(filename, InputFileCallbackPolicy::Close, _fileCallbackUserData); _fileCallback(filename, InputFileCallbackPolicy::Close, _fileCallbackUserData);
/* Shouldn't get here, the assert is fired already in setFileCallback() */ /* Shouldn't get here, the assert is fired already in setFileCallback() */
} else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
/* If opening succeeded, save the returned values. If not, the values were /* If opening succeeded, cache reported font properties. If not, the values
set to their default values by close() already. */ 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()) { if(isOpened()) {
const Properties properties = doProperties();
_size = properties.size; _size = properties.size;
_ascent = properties.ascent; _ascent = properties.ascent;
_descent = properties.descent; _descent = properties.descent;
@ -346,7 +394,7 @@ bool AbstractFont::openFile(const Containers::StringView filename, const Float s
return false; 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 #ifdef MAGNUM_BUILD_DEPRECATED
/* If this function is not implemented and opening data isn't supported /* If this function is not implemented and opening data isn't supported
either, assume the plugin implements only the deprecated doOpenFile() 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. */ API or not. */
if(!(features() & FontFeature::OpenData) && fontId != 0) { if(!(features() & FontFeature::OpenData) && fontId != 0) {
Error() << "Text::AbstractFont::openFile(): cannot open font at index" << fontId; Error() << "Text::AbstractFont::openFile(): cannot open font at index" << fontId;
return {}; return;
} }
#endif #endif
CORRADE_ASSERT(features() & FontFeature::OpenData, "Text::AbstractFont::openFile(): not implemented", {}); CORRADE_ASSERT(features() & FontFeature::OpenData,
"Text::AbstractFont::openFile(): not implemented", );
Properties properties;
/* If callbacks are set, use them. This is the same implementation as in /* If callbacks are set, use them. This is the same implementation as in
openFile(), see the comment there for details. */ openFile(), see the comment there for details. */
@ -370,10 +417,10 @@ auto AbstractFont::doOpenFile(const Containers::StringView filename, const Float
const Containers::Optional<Containers::ArrayView<const char>> data = _fileCallback(filename, InputFileCallbackPolicy::LoadTemporary, _fileCallbackUserData); const Containers::Optional<Containers::ArrayView<const char>> data = _fileCallback(filename, InputFileCallbackPolicy::LoadTemporary, _fileCallbackUserData);
if(!data) { if(!data) {
Error() << "Text::AbstractFont::openFile(): cannot open file" << filename; Error() << "Text::AbstractFont::openFile(): cannot open file" << filename;
return {}; return;
} }
properties = doOpenData(*data, size, fontId); doOpenData(*data, size, fontId);
_fileCallback(filename, InputFileCallbackPolicy::Close, _fileCallbackUserData); _fileCallback(filename, InputFileCallbackPolicy::Close, _fileCallbackUserData);
/* Otherwise open the file directly */ /* Otherwise open the file directly */
@ -381,13 +428,11 @@ auto AbstractFont::doOpenFile(const Containers::StringView filename, const Float
const Containers::Optional<Containers::Array<char>> data = Utility::Path::read(filename); const Containers::Optional<Containers::Array<char>> data = Utility::Path::read(filename);
if(!data) { if(!data) {
Error() << "Text::AbstractFont::openFile(): cannot open file" << filename; 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 #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 a plugin implements the new doOpenFile(), that implementation gets
called from here for fontId 0, and from openFile() for all other font called from here for fontId 0, and from openFile() for all other font
IDs. */ 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 #endif

78
src/Magnum/Text/AbstractFont.h

@ -725,7 +725,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
/** /**
* @brief Font properties * @brief Font properties
* *
* Returned from @ref doOpenFile(), @ref doOpenData(). * Returned from @ref doProperties().
*/ */
struct Properties { struct Properties {
#if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 #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() * @brief Implementation for @ref openFile()
* @m_since_latest * @m_since_latest
* *
* If @ref doIsOpened() returns @cpp true @ce after calling this * If the operation was successful, @ref doIsOpened() should return
* function, it's assumed that opening was successful and the * @cpp true @ce after calling this function, @cpp false @ce otherwise.
* @ref Properties are expected to contain valid values. If *
* @ref doIsOpened() returns @cpp false @ce, the returned values are * If @ref FontFeature::OpenData is supported, default implementation
* ignored. If @ref FontFeature::OpenData is supported, default * opens the file and calls @ref doOpenData() with its contents. It is
* implementation opens the file and calls @ref doOpenData() with its * allowed to call this function from your @ref doOpenFile()
* contents. It is allowed to call this function from your * implementation --- in particular, this implementation will also
* @ref doOpenFile() implementation --- in particular, this * correctly handle callbacks set through @ref setFileCallback().
* implementation will also correctly handle callbacks set through
* @ref setFileCallback().
* *
* This function is not called when file callbacks are set through * This function is not called when file callbacks are set through
* @ref setFileCallback() and @ref FontFeature::FileCallback is not * @ref setFileCallback() and @ref FontFeature::FileCallback is not
* supported --- instead, file is loaded though the callback and data * supported --- instead, file is loaded though the callback and data
* passed through to @ref doOpenData(). * 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 #ifdef MAGNUM_BUILD_DEPRECATED
/** /**
* @brief Implementation for @ref openFile() * @brief Implementation for @ref openFile()
* @m_deprecated_since_latest Implement @ref doOpenFile(Containers::StringView, Float, UnsignedInt) * @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 /* MSVC warns when overriding such methods and there's no way to
suppress that warning, making the RT build (which treats deprecation suppress that warning, making the RT build (which treats deprecation
warnings as errors) fail and other builds extremely noisy. So warnings as errors) fail and other builds extremely noisy. So
disabling those on MSVC. */ disabling those on MSVC. */
#if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) #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 #endif
virtual Properties doOpenFile(Containers::StringView filename, Float size); virtual Properties doOpenFile(Containers::StringView filename, Float size);
#endif #endif
@ -853,26 +857,29 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @brief Implementation for @ref openData() * @brief Implementation for @ref openData()
* @m_since_latest * @m_since_latest
* *
* If @ref doIsOpened() returns @cpp true @ce after calling this * If the operation was successful, @ref doIsOpened() should return
* function, it's assumed that opening was successful and the * @cpp true @ce after calling this function, @cpp false @ce otherwise.
* @ref Properties are expected to contain valid values. If
* @ref doIsOpened() returns @cpp false @ce, the returned values are
* ignored.
*/ */
virtual Properties doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId); virtual void doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId);
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
/** /**
* @brief Implementation for @ref openData() * @brief Implementation for @ref openData()
* @m_deprecated_since_latest Implement @ref doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) * @m_deprecated_since_latest Implement @ref doOpenData(Containers::ArrayView<const char>, 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 /* MSVC warns when overriding such methods and there's no way to
suppress that warning, making the RT build (which treats deprecation suppress that warning, making the RT build (which treats deprecation
warnings as errors) fail and other builds extremely noisy. So warnings as errors) fail and other builds extremely noisy. So
disabling those on MSVC. */ disabling those on MSVC. */
#if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG)) #if !(defined(CORRADE_TARGET_MSVC) && !defined(CORRADE_TARGET_CLANG))
CORRADE_DEPRECATED("implement doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) instead") CORRADE_DEPRECATED("implement doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) and doProperties() instead")
#endif #endif
virtual Properties doOpenData(Containers::ArrayView<const char> data, Float size); virtual Properties doOpenData(Containers::ArrayView<const char> data, Float size);
#endif #endif
@ -880,6 +887,25 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
/** @brief Implementation for @ref close() */ /** @brief Implementation for @ref close() */
virtual void doClose() = 0; 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() * @brief Implementation for @ref glyphIdsInto()
* @m_since_latest * @m_since_latest
@ -956,7 +982,13 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
#endif #endif
Float _size{}, _ascent{}, _descent{}, _lineHeight{}; 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 #ifdef MAGNUM_BUILD_DEPRECATED

360
src/Magnum/Text/Test/AbstractFontTest.cpp

@ -109,6 +109,9 @@ struct AbstractFontTest: TestSuite::Tester {
void openFileNotImplemented(); void openFileNotImplemented();
void openDataNotSupported(); void openDataNotSupported();
void openDataNotImplemented(); void openDataNotImplemented();
#ifdef MAGNUM_BUILD_DEPRECATED
void propertiesNotImplemented();
#endif
void setFileCallback(); void setFileCallback();
void setFileCallbackTemplate(); void setFileCallbackTemplate();
@ -210,6 +213,19 @@ const struct {
{"with a font opened", true} {"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() { AbstractFontTest::AbstractFontTest() {
addTests({&AbstractFontTest::debugFeature, addTests({&AbstractFontTest::debugFeature,
&AbstractFontTest::debugFeaturePacked, &AbstractFontTest::debugFeaturePacked,
@ -290,6 +306,11 @@ AbstractFontTest::AbstractFontTest() {
&AbstractFontTest::openDataNotImplemented}, &AbstractFontTest::openDataNotImplemented},
Containers::arraySize(OpenData)); Containers::arraySize(OpenData));
#ifdef MAGNUM_BUILD_DEPRECATED
addInstancedTests({&AbstractFontTest::propertiesNotImplemented},
Containers::arraySize(PropertiesNotImplementedData));
#endif
addTests({&AbstractFontTest::setFileCallback, addTests({&AbstractFontTest::setFileCallback,
&AbstractFontTest::setFileCallbackTemplate, &AbstractFontTest::setFileCallbackTemplate,
&AbstractFontTest::setFileCallbackTemplateNull, &AbstractFontTest::setFileCallbackTemplateNull,
@ -428,6 +449,7 @@ void AbstractFontTest::construct() {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -460,11 +482,11 @@ void AbstractFontTest::dataFontCount() {
return 37; return 37;
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
return {};
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -502,11 +524,11 @@ void AbstractFontTest::dataFontCountFailed() {
return {}; return {};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
return {};
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -542,6 +564,7 @@ void AbstractFontTest::dataFontCountNotImplemented() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -568,11 +591,11 @@ void AbstractFontTest::fileFontCount() {
return 37; return 37;
} }
Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { void doOpenFile(Containers::StringView, Float, UnsignedInt) override {
_opened = true; _opened = true;
return {};
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -609,11 +632,11 @@ void AbstractFontTest::fileFontCountFailed() {
return {}; return {};
} }
Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { void doOpenFile(Containers::StringView, Float, UnsignedInt) override {
_opened = true; _opened = true;
return {};
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -649,6 +672,7 @@ void AbstractFontTest::fileFontCountNotImplemented() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -678,11 +702,11 @@ void AbstractFontTest::fileFontCountAsData() {
return 37; return 37;
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
return {};
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -719,11 +743,11 @@ void AbstractFontTest::fileFontCountAsDataNotFound() {
return {}; return {};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
return {};
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -768,11 +792,11 @@ void AbstractFontTest::fileFontCountAsDataFailed() {
return {}; return {};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
return {};
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -808,6 +832,7 @@ void AbstractFontTest::fileFontCountAsDataNotImplemented() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -835,6 +860,7 @@ void AbstractFontTest::fontCountInvalid() {
return 0; return 0;
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -860,6 +886,7 @@ void AbstractFontTest::dataFontCountNotSupported() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -884,13 +911,17 @@ void AbstractFontTest::openData() {
_opened = false; _opened = false;
} }
Properties doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId) override { void doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId) override {
CORRADE_COMPARE_AS(data, CORRADE_COMPARE_AS(data,
Containers::arrayView({'\xa5'}), Containers::arrayView({'\xa5'}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE(size, 13.0f);
CORRADE_COMPARE(fontId, expectedFontId); CORRADE_COMPARE(fontId, expectedFontId);
_opened = true; _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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
@ -913,7 +944,7 @@ void AbstractFontTest::openData() {
supply a constant instead */ supply a constant instead */
CORRADE_VERIFY(font.openData(a5, 13.0f, data.fontId)); CORRADE_VERIFY(font.openData(a5, 13.0f, data.fontId));
CORRADE_VERIFY(font.isOpened()); 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.ascent(), 1.0f);
CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.descent(), 2.0f);
CORRADE_COMPARE(font.lineHeight(), 3.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f);
@ -1009,11 +1040,14 @@ void AbstractFontTest::openDataFailed() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
called = true; called = true;
return {};
} }
Properties doProperties() override {
CORRADE_FAIL("This should not be called");
return {};
}
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1080,11 +1114,15 @@ void AbstractFontTest::openFile() {
_opened = false; _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(filename, "hello.ttf");
CORRADE_COMPARE(size, 13.0f);
CORRADE_COMPARE(fontId, expectedFontId); CORRADE_COMPARE(fontId, expectedFontId);
_opened = true; _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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
@ -1106,7 +1144,7 @@ void AbstractFontTest::openFile() {
supply a constant instead */ supply a constant instead */
CORRADE_VERIFY(font.openFile("hello.ttf", 13.0f, data.fontId)); CORRADE_VERIFY(font.openFile("hello.ttf", 13.0f, data.fontId));
CORRADE_VERIFY(font.isOpened()); 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.ascent(), 1.0f);
CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.descent(), 2.0f);
CORRADE_COMPARE(font.lineHeight(), 3.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f);
@ -1198,11 +1236,14 @@ void AbstractFontTest::openFileFailed() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { void doOpenFile(Containers::StringView, Float, UnsignedInt) override {
called = true; called = true;
return {};
} }
Properties doProperties() override {
CORRADE_FAIL("This should not be called");
return {};
}
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1266,15 +1307,18 @@ void AbstractFontTest::openFileAsData() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId) override { void doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId) override {
CORRADE_COMPARE_AS(data, CORRADE_COMPARE_AS(data,
Containers::arrayView({'\xa5'}), Containers::arrayView({'\xa5'}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE(size, 13.0f);
CORRADE_COMPARE(fontId, expectedFontId); CORRADE_COMPARE(fontId, expectedFontId);
_opened = true; _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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1295,7 +1339,7 @@ void AbstractFontTest::openFileAsData() {
supply a constant instead */ supply a constant instead */
CORRADE_VERIFY(font.openFile(Utility::Path::join(TEXT_TEST_DIR, "data.bin"), 13.0f, data.fontId)); CORRADE_VERIFY(font.openFile(Utility::Path::join(TEXT_TEST_DIR, "data.bin"), 13.0f, data.fontId));
CORRADE_VERIFY(font.isOpened()); 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.ascent(), 1.0f);
CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.descent(), 2.0f);
CORRADE_COMPARE(font.lineHeight(), 3.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f);
@ -1311,11 +1355,14 @@ void AbstractFontTest::openFileAsDataNotFound() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); 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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1419,11 +1466,14 @@ void AbstractFontTest::openFileAsDataFailed() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
called = true; called = true;
return {};
} }
Properties doProperties() override {
CORRADE_FAIL("This should not be called");
return {};
}
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1490,6 +1540,7 @@ void AbstractFontTest::openFileNotImplemented() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1528,6 +1579,7 @@ void AbstractFontTest::openDataNotSupported() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1554,6 +1606,7 @@ void AbstractFontTest::openDataNotImplemented() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1580,6 +1633,49 @@ void AbstractFontTest::openDataNotImplemented() {
#endif #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<const char>, Float, UnsignedInt) override {
_opened = true;
}
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
Containers::Pointer<AbstractShaper> 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() { void AbstractFontTest::setFileCallback() {
struct: AbstractFont { struct: AbstractFont {
FontFeatures doFeatures() const override { return FontFeature::OpenData|FontFeature::FileCallback; } FontFeatures doFeatures() const override { return FontFeature::OpenData|FontFeature::FileCallback; }
@ -1589,6 +1685,7 @@ void AbstractFontTest::setFileCallback() {
*static_cast<int*>(userData) = 1337; *static_cast<int*>(userData) = 1337;
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1614,6 +1711,7 @@ void AbstractFontTest::setFileCallbackTemplate() {
called = true; called = true;
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1647,6 +1745,7 @@ void AbstractFontTest::setFileCallbackTemplateNull() {
called = true; called = true;
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1671,6 +1770,7 @@ void AbstractFontTest::setFileCallbackTemplateConst() {
called = true; called = true;
} }
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1697,6 +1797,7 @@ void AbstractFontTest::setFileCallbackFileOpened() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1717,6 +1818,7 @@ void AbstractFontTest::setFileCallbackNotImplemented() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1741,6 +1843,7 @@ void AbstractFontTest::setFileCallbackNotSupported() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1779,21 +1882,23 @@ void AbstractFontTest::setFileCallbackOpenFileDirectly() {
return {}; 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 */ /* Called because FileCallback is supported */
CORRADE_COMPARE(filename, "file.dat"); CORRADE_COMPARE(filename, "file.dat");
CORRADE_COMPARE(size, 42.0f);
CORRADE_COMPARE(fontId, expectedFontId); CORRADE_COMPARE(fontId, expectedFontId);
CORRADE_VERIFY(fileCallback()); CORRADE_VERIFY(fileCallback());
CORRADE_VERIFY(fileCallbackUserData()); CORRADE_VERIFY(fileCallbackUserData());
_opened = true; _opened = true;
return {size, 1.0f, 2.0f, 3.0f, 15};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); 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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -1822,7 +1927,7 @@ void AbstractFontTest::setFileCallbackOpenFileDirectly() {
supply a constant instead */ supply a constant instead */
CORRADE_VERIFY(font.openFile("file.dat", 42.0f, data.fontId)); CORRADE_VERIFY(font.openFile("file.dat", 42.0f, data.fontId));
CORRADE_VERIFY(font.isOpened()); 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.ascent(), 1.0f);
CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.descent(), 2.0f);
CORRADE_COMPARE(font.lineHeight(), 3.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f);
@ -1849,9 +1954,8 @@ void AbstractFontTest::setFileCallbackOpenFileDirectlyDeprecated() {
return {size, 1.0f, 2.0f, 3.0f, 15}; return {size, 1.0f, 2.0f, 3.0f, 15};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
return {};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float) override { Properties doOpenData(Containers::ArrayView<const char>, Float) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
@ -1959,16 +2063,18 @@ void AbstractFontTest::setFileCallbackOpenFileDirectlyFailed() {
return {}; return {};
} }
Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { void doOpenFile(Containers::StringView, Float, UnsignedInt) override {
openCalled = true; openCalled = true;
return {};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); 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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -2016,9 +2122,8 @@ void AbstractFontTest::setFileCallbackOpenFileDirectlyFailedDeprecated() {
return {}; return {};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
return {};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float) override { Properties doOpenData(Containers::ArrayView<const char>, Float) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
@ -2072,24 +2177,28 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementation() {
return 37; 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(filename, "file.dat");
CORRADE_COMPARE(size, 42.0f);
CORRADE_COMPARE(fontId, expectedFontId); CORRADE_COMPARE(fontId, expectedFontId);
CORRADE_VERIFY(fileCallback()); CORRADE_VERIFY(fileCallback());
CORRADE_VERIFY(fileCallbackUserData()); CORRADE_VERIFY(fileCallbackUserData());
openCalled = true; openCalled = true;
return AbstractFont::doOpenFile(filename, size, fontId); AbstractFont::doOpenFile(filename, size, fontId);
} }
Properties doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId) override { void doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId) override {
CORRADE_COMPARE_AS(data, CORRADE_COMPARE_AS(data,
Containers::arrayView({'\xb0'}), Containers::arrayView({'\xb0'}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE(size, 42.0f);
CORRADE_COMPARE(fontId, expectedFontId); CORRADE_COMPARE(fontId, expectedFontId);
_opened = true; _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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -2141,7 +2250,7 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementation() {
CORRADE_VERIFY(font.openCalled); CORRADE_VERIFY(font.openCalled);
CORRADE_COMPARE(state.loaded, 2); CORRADE_COMPARE(state.loaded, 2);
CORRADE_COMPARE(state.closed, 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.ascent(), 1.0f);
CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.descent(), 2.0f);
CORRADE_COMPARE(font.lineHeight(), 3.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f);
@ -2244,16 +2353,19 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementationNotFound(
return 37; return 37;
} }
Properties doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { void doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override {
openCalled = true; openCalled = true;
return AbstractFont::doOpenFile(filename, size, fontId); AbstractFont::doOpenFile(filename, size, fontId);
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); 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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -2312,16 +2424,19 @@ void AbstractFontTest::setFileCallbackOpenFileThroughBaseImplementationFailed()
return {}; return {};
} }
Properties doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override { void doOpenFile(Containers::StringView filename, Float size, UnsignedInt fontId) override {
openFileCalled = true; openFileCalled = true;
return AbstractFont::doOpenFile(filename, size, fontId); AbstractFont::doOpenFile(filename, size, fontId);
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
openDataCalled = true; openDataCalled = true;
return {};
} }
Properties doProperties() override {
CORRADE_FAIL("This should not be called");
return {};
}
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -2464,18 +2579,21 @@ void AbstractFontTest::setFileCallbackOpenFileAsData() {
return 37; return 37;
} }
Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { void doOpenFile(Containers::StringView, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
return {};
} }
Properties doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId) override { void doOpenData(Containers::ArrayView<const char> data, Float size, UnsignedInt fontId) override {
CORRADE_COMPARE_AS(data, CORRADE_COMPARE_AS(data,
Containers::arrayView({'\xb0'}), Containers::arrayView({'\xb0'}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE(size, 13.0f);
CORRADE_COMPARE(fontId, expectedFontId); CORRADE_COMPARE(fontId, expectedFontId);
_opened = true; _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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
@ -2523,7 +2641,7 @@ void AbstractFontTest::setFileCallbackOpenFileAsData() {
CORRADE_VERIFY(font.isOpened()); CORRADE_VERIFY(font.isOpened());
CORRADE_COMPARE(state.loaded, 2); CORRADE_COMPARE(state.loaded, 2);
CORRADE_COMPARE(state.closed, 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.ascent(), 1.0f);
CORRADE_COMPARE(font.descent(), 2.0f); CORRADE_COMPARE(font.descent(), 2.0f);
CORRADE_COMPARE(font.lineHeight(), 3.0f); CORRADE_COMPARE(font.lineHeight(), 3.0f);
@ -2541,9 +2659,8 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataDeprecated() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override { _opened = false; } 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"); CORRADE_FAIL("This should not be called");
return {};
} }
Properties doOpenFile(Containers::StringView, Float) override { Properties doOpenFile(Containers::StringView, Float) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
@ -2609,9 +2726,8 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataDeprecatedNonZeroFontId() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override { _opened = false; } 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"); CORRADE_FAIL("This should not be called");
return {};
} }
Properties doOpenFile(Containers::StringView, Float) override { Properties doOpenFile(Containers::StringView, Float) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
@ -2680,16 +2796,18 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataNotFound() {
return {}; return {};
} }
Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { void doOpenFile(Containers::StringView, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
return {};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); 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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -2741,16 +2859,18 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataFailed() {
return {}; return {};
} }
Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { void doOpenFile(Containers::StringView, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
return {};
} }
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
openCalled = true; openCalled = true;
return {};
} }
Properties doProperties() override {
CORRADE_FAIL("This should not be called");
return {};
}
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -2812,9 +2932,8 @@ void AbstractFontTest::setFileCallbackOpenFileAsDataFailedDeprecated() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doOpenFile(Containers::StringView, Float, UnsignedInt) override { void doOpenFile(Containers::StringView, Float, UnsignedInt) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
return {};
} }
Properties doOpenFile(Containers::StringView, Float) override { Properties doOpenFile(Containers::StringView, Float) override {
CORRADE_FAIL("This should not be called"); CORRADE_FAIL("This should not be called");
@ -2871,11 +2990,13 @@ void AbstractFontTest::properties() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float size, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -2884,7 +3005,7 @@ void AbstractFontTest::properties() {
bool _opened = false; bool _opened = false;
} font; } font;
CORRADE_VERIFY(font.openData(nullptr, 13.0f)); CORRADE_VERIFY(font.openData(nullptr, 0.0f));
CORRADE_VERIFY(font.isOpened()); CORRADE_VERIFY(font.isOpened());
CORRADE_COMPARE(font.size(), 13.0f); CORRADE_COMPARE(font.size(), 13.0f);
CORRADE_COMPARE(font.ascent(), 1.0f); CORRADE_COMPARE(font.ascent(), 1.0f);
@ -2901,6 +3022,7 @@ void AbstractFontTest::propertiesNoFont() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -2930,8 +3052,11 @@ void AbstractFontTest::glyphId() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 1280}; return {0.0f, 0.0f, 0.0f, 0.0f, 1280};
} }
@ -2970,6 +3095,7 @@ void AbstractFontTest::glyphIdNoFont() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -2994,6 +3120,7 @@ void AbstractFontTest::glyphIdInvalidSize() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3019,11 +3146,13 @@ void AbstractFontTest::glyphIdOutOfRange() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _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 char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>& glyphs) override { void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>& glyphs) override {
for(std::size_t i = 0; i != glyphs.size(); ++i) for(std::size_t i = 0; i != glyphs.size(); ++i)
glyphs[i] = i; glyphs[i] = i;
@ -3058,8 +3187,11 @@ void AbstractFontTest::glyphName() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 4}; return {0.0f, 0.0f, 0.0f, 0.0f, 4};
} }
@ -3093,8 +3225,11 @@ void AbstractFontTest::glyphNameNotImplemented() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 4}; return {0.0f, 0.0f, 0.0f, 0.0f, 4};
} }
@ -3122,6 +3257,7 @@ void AbstractFontTest::glyphNameNoFont() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3147,8 +3283,11 @@ void AbstractFontTest::glyphNameOutOfRange() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 4}; return {0.0f, 0.0f, 0.0f, 0.0f, 4};
} }
@ -3180,8 +3319,11 @@ void AbstractFontTest::glyphSizeAdvance() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 98}; return {0.0f, 0.0f, 0.0f, 0.0f, 98};
} }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
@ -3206,6 +3348,7 @@ void AbstractFontTest::glyphSizeAdvanceNoFont() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3229,8 +3372,11 @@ void AbstractFontTest::glyphSizeAdvanceOutOfRange() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 3}; return {0.0f, 0.0f, 0.0f, 0.0f, 3};
} }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
@ -3268,8 +3414,11 @@ void AbstractFontTest::fillGlyphCache() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 17}; return {0.0f, 0.0f, 0.0f, 0.0f, 17};
} }
@ -3320,8 +3469,11 @@ void AbstractFontTest::fillGlyphCacheOutOfRange() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 16}; return {0.0f, 0.0f, 0.0f, 0.0f, 16};
} }
@ -3357,8 +3509,11 @@ void AbstractFontTest::fillGlyphCacheNotUnique() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 16}; return {0.0f, 0.0f, 0.0f, 0.0f, 16};
} }
@ -3390,8 +3545,11 @@ void AbstractFontTest::fillGlyphCacheFromString() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 17}; return {0.0f, 0.0f, 0.0f, 0.0f, 17};
} }
@ -3458,8 +3616,11 @@ void AbstractFontTest::fillGlyphCacheFailed() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 1}; return {0.0f, 0.0f, 0.0f, 0.0f, 1};
} }
@ -3500,6 +3661,7 @@ void AbstractFontTest::fillGlyphCacheNotSupported() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>& glyphs) override { void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>& glyphs) override {
/* Set all to 0 to avoid an assert that the IDs are out of range */ /* Set all to 0 to avoid an assert that the IDs are out of range */
for(UnsignedInt& i: glyphs) for(UnsignedInt& i: glyphs)
@ -3532,8 +3694,11 @@ void AbstractFontTest::fillGlyphCacheNotImplemented() {
bool doIsOpened() const override { return _opened; } bool doIsOpened() const override { return _opened; }
void doClose() override {} void doClose() override {}
Properties doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override { void doOpenData(Containers::ArrayView<const char>, Float, UnsignedInt) override {
_opened = true; _opened = true;
}
Properties doProperties() override {
return {0.0f, 0.0f, 0.0f, 0.0f, 1}; return {0.0f, 0.0f, 0.0f, 0.0f, 1};
} }
@ -3569,6 +3734,7 @@ void AbstractFontTest::fillGlyphCacheNoFont() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3595,6 +3761,7 @@ void AbstractFontTest::fillGlyphCacheInvalidUtf8() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3614,6 +3781,7 @@ void AbstractFontTest::createGlyphCache() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3638,6 +3806,7 @@ void AbstractFontTest::createGlyphCacheNotSupported() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3658,6 +3827,7 @@ void AbstractFontTest::createGlyphCacheNotImplemented() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3678,6 +3848,7 @@ void AbstractFontTest::createGlyphCacheNoFont() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3708,6 +3879,7 @@ void AbstractFontTest::createShaper() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3726,6 +3898,7 @@ void AbstractFontTest::createShaperNoFont() {
bool doIsOpened() const override { return false; } bool doIsOpened() const override { return false; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
@ -3746,6 +3919,7 @@ void AbstractFontTest::createShaperNullptr() {
bool doIsOpened() const override { return true; } bool doIsOpened() const override { return true; }
void doClose() override {} void doClose() override {}
Properties doProperties() override { return {}; }
void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {} void doGlyphIdsInto(const Containers::StridedArrayView1D<const char32_t>&, const Containers::StridedArrayView1D<UnsignedInt>&) override {}
Vector2 doGlyphSize(UnsignedInt) override { return {}; } Vector2 doGlyphSize(UnsignedInt) override { return {}; }
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }

Loading…
Cancel
Save