diff --git a/src/Text/Font.cpp b/src/Text/Font.cpp index a2d02e97a..cffabf54b 100644 --- a/src/Text/Font.cpp +++ b/src/Text/Font.cpp @@ -19,6 +19,7 @@ #include #include FT_FREETYPE_H #include +#include #include "Extensions.h" #include "Image.h" @@ -62,8 +63,13 @@ void Font::prerender(const std::string& characters, const Vector2i& atlasSize) { /** @bug Crash when atlas is too small */ /* Get character codes from string */ - /** @todo proper UTF-8 decoding */ - std::vector charCodes(characters.begin(), characters.end()); + std::vector charCodes; + charCodes.reserve(characters.size()); + 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); + } /* Get character indices */ std::vector charIndices; diff --git a/src/Text/Font.h b/src/Text/Font.h index 07cc72761..1c12d55f2 100644 --- a/src/Text/Font.h +++ b/src/Text/Font.h @@ -86,7 +86,7 @@ class MAGNUM_TEXT_EXPORT Font { /** * @brief Prerender given character set - * @param characters Characters to render + * @param characters UTF-8 characters to render * @param atlasSize Size of resulting atlas * * Creates new atlas with prerendered characters, replacing the