diff --git a/src/Text/GlyphCache.cpp b/src/Text/GlyphCache.cpp index 6fbfc5313..a11338b0a 100644 --- a/src/Text/GlyphCache.cpp +++ b/src/Text/GlyphCache.cpp @@ -69,7 +69,8 @@ void GlyphCache::initialize(const TextureFormat internalFormat, const Vector2i& } std::vector GlyphCache::reserve(const std::vector& sizes) { - CORRADE_ASSERT(glyphs.empty(), "Text::GlyphCache::reserve(): reserving space in non-empty cache is not yet implemented", {}); + CORRADE_ASSERT((glyphs.size() == 1 && glyphs.at(0) == std::pair()), + "Text::GlyphCache::reserve(): reserving space in non-empty cache is not yet implemented", {}); glyphs.reserve(glyphs.size() + sizes.size()); return TextureTools::atlas(_size, sizes, _padding); } diff --git a/src/Text/Test/GlyphCacheGLTest.cpp b/src/Text/Test/GlyphCacheGLTest.cpp index a46e8f583..7578f57b5 100644 --- a/src/Text/Test/GlyphCacheGLTest.cpp +++ b/src/Text/Test/GlyphCacheGLTest.cpp @@ -33,11 +33,13 @@ class GlyphCacheGLTest: public Magnum::Test::AbstractOpenGLTester { void initialize(); void access(); + void reserve(); }; GlyphCacheGLTest::GlyphCacheGLTest() { addTests({&GlyphCacheGLTest::initialize, - &GlyphCacheGLTest::access}); + &GlyphCacheGLTest::access, + &GlyphCacheGLTest::reserve}); } void GlyphCacheGLTest::initialize() { @@ -78,6 +80,13 @@ void GlyphCacheGLTest::access() { CORRADE_COMPARE(rectangle, Rectanglei({10, 10}, {23, 45})); } +void GlyphCacheGLTest::reserve() { + Text::GlyphCache cache(Vector2i(236)); + + /* Verify that this works for "empty" cache */ + CORRADE_VERIFY(!cache.reserve({{5, 3}}).empty()); +} + }}} CORRADE_TEST_MAIN(Magnum::Text::Test::GlyphCacheGLTest)