diff --git a/src/Text/AbstractFont.cpp b/src/Text/AbstractFont.cpp index 741d1b48c..ba2039a88 100644 --- a/src/Text/AbstractFont.cpp +++ b/src/Text/AbstractFont.cpp @@ -106,16 +106,7 @@ void AbstractFont::close() { void AbstractFont::createGlyphCache(GlyphCache* const cache, const std::string& characters) { CORRADE_ASSERT(isOpened(), "Text::AbstractFont::createGlyphCache(): no font opened", ); - /* Get glyph codes from characters */ - std::u32string unicodeCharacters; - unicodeCharacters.reserve(characters.size()+1); - for(std::size_t i = 0; i != characters.size(); ) { - char32_t unicode; - std::tie(unicode, i) = Utility::Unicode::nextChar(characters, i); - unicodeCharacters.push_back(unicode); - } - - doCreateGlyphCache(cache, unicodeCharacters); + doCreateGlyphCache(cache, Utility::Unicode::utf32(characters)); } AbstractLayouter* AbstractFont::layout(const GlyphCache* const cache, const Float size, const std::string& text) { diff --git a/src/Text/Test/AbstractFontTest.cpp b/src/Text/Test/AbstractFontTest.cpp index 4447b9aaa..ae0c147e9 100644 --- a/src/Text/Test/AbstractFontTest.cpp +++ b/src/Text/Test/AbstractFontTest.cpp @@ -38,15 +38,11 @@ class AbstractFontTest: public TestSuite::Tester { void openSingleData(); void openFile(); - - void createGlyphCache(); }; AbstractFontTest::AbstractFontTest() { addTests({&AbstractFontTest::openSingleData, - &AbstractFontTest::openFile, - - &AbstractFontTest::createGlyphCache}); + &AbstractFontTest::openFile}); } namespace { @@ -89,30 +85,6 @@ void AbstractFontTest::openFile() { CORRADE_VERIFY(font.isOpened()); } -void AbstractFontTest::createGlyphCache() { - class CachingFont: public Text::AbstractFont { - public: - std::u32string cacheCharacters; - - private: - Features doFeatures() const override { return {}; } - bool doIsOpened() const override { return true; } - void doClose() override {} - - void doCreateGlyphCache(GlyphCache*, const std::u32string& characters) override { - cacheCharacters = characters; - } - - AbstractLayouter* doLayout(const GlyphCache*, Float, const std::string&) override { - return nullptr; - } - }; - - CachingFont font; - font.createGlyphCache(nullptr, "žluťoučký kůň"); - CORRADE_COMPARE(font.cacheCharacters, U"\u017Elu\u0165ou\u010Dk\u00FD k\u016F\u0148"); -} - }}} CORRADE_TEST_MAIN(Magnum::Text::Test::AbstractFontTest)