summaryrefslogtreecommitdiff
path: root/plugingui/font.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-09-06 11:23:43 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-09-06 11:23:43 +0200
commitb15870b7cb63316060a5ff565cf980a981633135 (patch)
tree545db2d5a9acd193003ddc08bdd2ae0cf13c21b7 /plugingui/font.cc
parentacbeb0cc1b18c4f62ff8d1ac50adf6406235a36b (diff)
Fix crash when trying to display non ascii characters.
Diffstat (limited to 'plugingui/font.cc')
-rw-r--r--plugingui/font.cc15
1 files changed, 9 insertions, 6 deletions
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 <cassert>
+
+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)