void MagnumFontGLTest::createGlyphCache() { MagnumFont font; CORRADE_VERIFY(font.openFile(Utility::Directory::join(MAGNUMFONT_TEST_DIR, "font.conf"), 0.0f)); /* Just testing that nothing crashes, asserts or errors */ std::unique_ptr<GlyphCache> cache = font.createGlyphCache(); MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(cache); CORRADE_COMPARE(cache->glyphCount(), 3); /** @todo properly test contents */ }
void MagnumFontGLTest::properties() { MagnumFont font; CORRADE_VERIFY(font.openFile(Utility::Directory::join(MAGNUMFONT_TEST_DIR, "font.conf"), 0.0f)); CORRADE_COMPARE(font.size(), 16.0f); CORRADE_COMPARE(font.ascent(), 25.0f); CORRADE_COMPARE(font.descent(), -10.0f); CORRADE_COMPARE(font.lineHeight(), 39.7333f); CORRADE_COMPARE(font.glyphAdvance(font.glyphId(U'W')), Vector2(23.0f, 0.0f)); }
void MagnumFontGLTest::layout() { MagnumFont font; CORRADE_VERIFY(font.openFile(Utility::Directory::join(MAGNUMFONT_TEST_DIR, "font.conf"), 0.0f)); /* Fill the cache with some fake glyphs */ GlyphCache cache(Vector2i(256)); cache.insert(font.glyphId(U'W'), {25, 34}, {{0, 8}, {16, 128}}); cache.insert(font.glyphId(U'e'), {25, 12}, {{16, 4}, {64, 32}}); auto layouter = font.layout(cache, 0.5f, "Wave"); CORRADE_VERIFY(layouter); CORRADE_COMPARE(layouter->glyphCount(), 4); Range2D rectangle; Range2D position; Range2D textureCoordinates; /* 'W' */ Vector2 cursorPosition; std::tie(position, textureCoordinates) = layouter->renderGlyph(0, cursorPosition = {}, rectangle); CORRADE_COMPARE(position, Range2D({0.78125f, 1.0625f}, {1.28125f, 4.8125f})); CORRADE_COMPARE(textureCoordinates, Range2D({0, 0.03125f}, {0.0625f, 0.5f})); CORRADE_COMPARE(cursorPosition, Vector2(0.71875f, 0.0f)); /* 'a' (not found) */ std::tie(position, textureCoordinates) = layouter->renderGlyph(1, cursorPosition = {}, rectangle); CORRADE_COMPARE(position, Range2D()); CORRADE_COMPARE(textureCoordinates, Range2D()); CORRADE_COMPARE(cursorPosition, Vector2(0.25f, 0.0f)); /* 'v' (not found) */ std::tie(position, textureCoordinates) = layouter->renderGlyph(2, cursorPosition = {}, rectangle); CORRADE_COMPARE(position, Range2D()); CORRADE_COMPARE(textureCoordinates, Range2D()); CORRADE_COMPARE(cursorPosition, Vector2(0.25f, 0.0f)); /* 'e' */ std::tie(position, textureCoordinates) = layouter->renderGlyph(3, cursorPosition = {}, rectangle); CORRADE_COMPARE(position, Range2D({0.78125f, 0.375f}, {2.28125f, 1.25f})); CORRADE_COMPARE(textureCoordinates, Range2D({0.0625f, 0.015625f}, {0.25f, 0.125f})); CORRADE_COMPARE(cursorPosition, Vector2(0.375f, 0.0f)); }