diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index a45fcfc48..9a4b054f5 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -44,6 +44,7 @@ #include #include #include "debug.h" +#include #include #include using namespace std; @@ -438,21 +439,22 @@ std::string trim(std::string &str, const std::string &trimChars /*= " \n\r\t"*/) return result.erase(0, result.find_first_not_of(trimChars)); } -std::string cutString(const std::string str, Font *msgFont, const int width) +std::string cutString(const std::string str, int msgFont, const int width) { + Font *msgFont_ = g_Font[msgFont]; std::string ret = str; ret = trim(ret); - int sw = msgFont->getRenderWidth(ret); + int sw = msgFont_->getRenderWidth(ret); if (sw <= width) return ret; else { std::string z = "..."; - int zw = msgFont->getRenderWidth(z); + int zw = msgFont_->getRenderWidth(z); if (width <= 2*zw) return ret; do { ret = ret.substr(0, ret.length()-1); - sw = msgFont->getRenderWidth(ret); + sw = msgFont_->getRenderWidth(ret); } while (sw+zw > width); ret = trim(ret) + z; } diff --git a/src/system/helpers.h b/src/system/helpers.h index 5d9efa8d9..3b26a12a6 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -37,8 +37,6 @@ #include #include -#include - int my_system(const char * cmd); int my_system(int argc, const char *arg, ...); /* argc is number of arguments including command */ @@ -69,7 +67,7 @@ std::string getFileName(std::string &file); std::string getFileExt(std::string &file); std::string getNowTimeStr(const char* format); std::string trim(std::string &str, const std::string &trimChars = " \n\r\t"); -std::string cutString(const std::string str, Font *msgFont, const int width); +std::string cutString(const std::string str, int msgFont, const int width); std::string strftime(const char *format, const struct tm *tm); std::string strftime(const char *format, time_t when, bool gm = false); time_t toEpoch(std::string &date);