Browse Source

Text: code cleanup -- merged two loops into one.

pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
1cf2087817
  1. 15
      src/Text/Font.cpp

15
src/Text/Font.cpp

@ -62,21 +62,16 @@ void Font::prerender(const std::string& characters, const Vector2i& atlasSize) {
/** @bug Crash when atlas is too small */
/* Get character codes from string */
std::vector<std::uint32_t> charCodes;
charCodes.reserve(characters.size());
/* Get glyph codes from characters */
std::vector<FT_UInt> charIndices;
charIndices.reserve(characters.size()+1);
charIndices.push_back(0);
for(std::size_t i = 0; i != characters.size(); ) {
std::uint32_t codepoint;
std::tie(codepoint, i) = Corrade::Utility::Unicode::nextChar(characters, i);
charCodes.push_back(codepoint);
charIndices.push_back(FT_Get_Char_Index(_ftFont, codepoint));
}
/* Get character indices */
std::vector<FT_UInt> charIndices;
charIndices.push_back(0);
for(std::uint32_t charCode: charCodes)
charIndices.push_back(FT_Get_Char_Index(_ftFont, charCode));
/* Remove duplicates (e.g. uppercase and lowercase mapped to same glyph) */
std::sort(charIndices.begin(), charIndices.end());
charIndices.erase(std::unique(charIndices.begin(), charIndices.end()), charIndices.end());

Loading…
Cancel
Save