diff --git a/src/Text/Font.cpp b/src/Text/Font.cpp index de8627bee..2bdfce706 100644 --- a/src/Text/Font.cpp +++ b/src/Text/Font.cpp @@ -15,6 +15,7 @@ #include "Font.h" +#include #include #include FT_FREETYPE_H #include @@ -49,7 +50,6 @@ void Font::prerender(const std::string& characters, const Vector2i& atlasSize) { glyphs.clear(); /** @bug Crash when atlas is too small */ - /** @todo Get rid of duplicate characters */ /* Get character codes from string */ /** @todo proper UTF-8 decoding */ @@ -61,6 +61,10 @@ void Font::prerender(const std::string& characters, const Vector2i& atlasSize) { 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()); + /* Sizes of all characters */ std::vector charSizes; charSizes.reserve(charIndices.size());