Browse Source

Text: debug output for AbstractFont::Feature[s].

audio-import
Vladimír Vondruš 7 years ago
parent
commit
7fefac955a
  1. 21
      src/Magnum/Text/AbstractFont.cpp
  2. 6
      src/Magnum/Text/AbstractFont.h
  3. 22
      src/Magnum/Text/Test/AbstractFontTest.cpp

21
src/Magnum/Text/AbstractFont.cpp

@ -238,6 +238,27 @@ Containers::Pointer<AbstractLayouter> AbstractFont::layout(const AbstractGlyphCa
return doLayout(cache, size, text); return doLayout(cache, size, text);
} }
Debug& operator<<(Debug& debug, const AbstractFont::Feature value) {
switch(value) {
/* LCOV_EXCL_START */
#define _c(v) case AbstractFont::Feature::v: return debug << "Text::AbstractFont::Feature::" #v;
_c(OpenData)
_c(FileCallback)
_c(PreparedGlyphCache)
#undef _c
/* LCOV_EXCL_STOP */
}
return debug << "Text::AbstractFont::Feature(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const AbstractFont::Features value) {
return Containers::enumSetDebugOutput(debug, value, "Text::AbstractFont::Features{}", {
AbstractFont::Feature::OpenData,
AbstractFont::Feature::FileCallback,
AbstractFont::Feature::PreparedGlyphCache});
}
AbstractLayouter::AbstractLayouter(UnsignedInt glyphCount): _glyphCount(glyphCount) {} AbstractLayouter::AbstractLayouter(UnsignedInt glyphCount): _glyphCount(glyphCount) {}
AbstractLayouter::~AbstractLayouter() = default; AbstractLayouter::~AbstractLayouter() = default;

6
src/Magnum/Text/AbstractFont.h

@ -528,6 +528,12 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
CORRADE_ENUMSET_OPERATORS(AbstractFont::Features) CORRADE_ENUMSET_OPERATORS(AbstractFont::Features)
/** @debugoperatorclassenum{AbstractFont,AbstractFont::Feature} */
MAGNUM_TEXT_EXPORT Debug& operator<<(Debug& debug, AbstractFont::Feature value);
/** @debugoperatorclassenum{AbstractFont,AbstractFont::Features} */
MAGNUM_TEXT_EXPORT Debug& operator<<(Debug& debug, AbstractFont::Features value);
/** /**
@brief Base for text layouters @brief Base for text layouters

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

@ -85,6 +85,9 @@ struct AbstractFontTest: TestSuite::Tester {
void createGlyphCacheNotSupported(); void createGlyphCacheNotSupported();
void createGlyphCacheNotImplemented(); void createGlyphCacheNotImplemented();
void createGlyphCacheNoFont(); void createGlyphCacheNoFont();
void debugFeature();
void debugFeatures();
}; };
AbstractFontTest::AbstractFontTest() { AbstractFontTest::AbstractFontTest() {
@ -131,7 +134,10 @@ AbstractFontTest::AbstractFontTest() {
&AbstractFontTest::createGlyphCache, &AbstractFontTest::createGlyphCache,
&AbstractFontTest::createGlyphCacheNotSupported, &AbstractFontTest::createGlyphCacheNotSupported,
&AbstractFontTest::createGlyphCacheNotImplemented, &AbstractFontTest::createGlyphCacheNotImplemented,
&AbstractFontTest::createGlyphCacheNoFont}); &AbstractFontTest::createGlyphCacheNoFont,
&AbstractFontTest::debugFeature,
&AbstractFontTest::debugFeatures});
} }
void AbstractFontTest::openData() { void AbstractFontTest::openData() {
@ -1022,6 +1028,20 @@ void AbstractFontTest::createGlyphCacheNoFont() {
CORRADE_COMPARE(out.str(), "Text::AbstractFont::createGlyphCache(): no font opened\n"); CORRADE_COMPARE(out.str(), "Text::AbstractFont::createGlyphCache(): no font opened\n");
} }
void AbstractFontTest::debugFeature() {
std::ostringstream out;
Debug{&out} << AbstractFont::Feature::OpenData << AbstractFont::Feature(0xf0);
CORRADE_COMPARE(out.str(), "Text::AbstractFont::Feature::OpenData Text::AbstractFont::Feature(0xf0)\n");
}
void AbstractFontTest::debugFeatures() {
std::ostringstream out;
Debug{&out} << (AbstractFont::Feature::OpenData|AbstractFont::Feature::PreparedGlyphCache) << AbstractFont::Features{};
CORRADE_COMPARE(out.str(), "Text::AbstractFont::Feature::OpenData|Text::AbstractFont::Feature::PreparedGlyphCache Text::AbstractFont::Features{}\n");
}
}}}} }}}}
CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontTest) CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontTest)

Loading…
Cancel
Save