Fix non-English language support

Non-ASCII characters have codes larger than 127. When used as indices,
these must be treated as unsigned.
This commit is contained in:
Vsevolod Kremianskii 2021-05-03 12:20:42 +07:00
parent 0a4f7f7fe5
commit e5fab733b5

View file

@ -82,7 +82,7 @@ void Font::draw(const string &text, const glm::vec3 &position, const glm::vec3 &
for (int i = 0; i < numBlocks; ++i) { for (int i = 0; i < numBlocks; ++i) {
int numChars = glm::min(kMaxCharacters, static_cast<int>(text.size()) - i * kMaxCharacters); int numChars = glm::min(kMaxCharacters, static_cast<int>(text.size()) - i * kMaxCharacters);
for (int j = 0; j < numChars; ++j) { for (int j = 0; j < numChars; ++j) {
const Glyph &glyph = _glyphs[static_cast<int>(text[i * kMaxCharacters + j])]; const Glyph &glyph = _glyphs[static_cast<unsigned char>(text[i * kMaxCharacters + j])];
glm::vec4 posScale; glm::vec4 posScale;
posScale[0] = position.x + textOffset.x; posScale[0] = position.x + textOffset.x;