Major rewrite of scripting support:
[supertux.git] / src / video / font.cpp
index bc46d9b..f007dab 100644 (file)
@@ -28,6 +28,7 @@
 #include "screen.hpp"
 #include "font.hpp"
 #include "drawing_context.hpp"
+#include "msg.hpp"
 
 Font::Font(const std::string& file, const std::string& shadowfile,
            int w, int h, int shadowsize)
@@ -113,6 +114,9 @@ Font::draw(const std::string& text, const Vector& pos_, FontAlignment alignment,
       l = text.size();
       done = true;
     }
+
+    if(l > sizeof(temp)-1)
+      l = sizeof(temp)-1;
     
     temp[text.copy(temp, l - i, i)] = '\0';
     
@@ -210,17 +214,13 @@ Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos,
     if(c >= 0x80) {
       font_index -= 32;
       if(c <= 0xa0) {
-#ifdef DEBUG
-        std::cout << "Unsupported utf-8 character '" << c << "' found\n";
-#endif
+        msg_debug << "Unsupported utf-8 character '" << c << "' found" << std::endl;
         font_index = 0;
       }
     }
         
     if(font_index < 0 || font_index >= (ssize_t) char_count) {
-#ifdef DEBUG
-      std::cout << "Unsupported utf-8 character found\n";
-#endif
+      msg_debug << "Unsupported utf-8 character found" << std::endl;
       font_index = 0;
     }