Browse Source

Text: using utility function instead of own (bugged) implementation.

Also removed the test, as there is now nothing to test.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
60d4f8066a
  1. 11
      src/Text/AbstractFont.cpp
  2. 30
      src/Text/Test/AbstractFontTest.cpp

11
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) {

30
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)

Loading…
Cancel
Save