From b15870b7cb63316060a5ff565cf980a981633135 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 6 Sep 2016 11:23:43 +0200 Subject: Fix crash when trying to display non ascii characters. --- plugingui/font.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'plugingui') diff --git a/plugingui/font.cc b/plugingui/font.cc index 3be7dd5..a9b102e 100644 --- a/plugingui/font.cc +++ b/plugingui/font.cc @@ -26,13 +26,16 @@ */ #include "font.h" -namespace GUI { +#include + +namespace GUI +{ Font::Font(const std::string& fontfile) : img_font(fontfile) { - size_t px = 0; - size_t c; + std::size_t px = 0; + std::size_t c; for(c = 0; c < (characters.size() - 1) && px < img_font.width(); ++c) { @@ -73,7 +76,7 @@ size_t Font::textWidth(const std::string& text) const { size_t len = 0; - for(auto cha : text) + for(unsigned char cha : text) { auto& character = characters[cha]; len += character.width + spacing + character.post_bias; @@ -103,9 +106,9 @@ PixelBufferAlpha *Font::render(const std::string& text) const new PixelBufferAlpha(textWidth(text), textHeight(text)); int x_offset = 0; - for(auto cha : text) + for(unsigned char cha : text) { - auto& character = characters[cha]; + auto& character = characters.at(cha); for(size_t x = 0; x < character.width; ++x) { for(size_t y = 0; y < img_font.height(); ++y) -- cgit v1.2.3