Fix wrapping text text cut-off

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 8a2db05c36
commit d706dbe3f2
  1. BIN
      C++ProjectTemplate
  2. 13
      main.cpp

Binary file not shown.

@ -2627,8 +2627,11 @@ goes on a very long time, I hope you can understand this is only for testing pur
std::string Wrap(std::string str,vd2d size,bool proportional) { std::string Wrap(std::string str,vd2d size,bool proportional) {
int marker=0; int marker=0;
std::string newStr=""; std::string newStr="";
bool firstChar=false;
while (marker<str.length()) { while (marker<str.length()) {
newStr+=str[marker]; if (firstChar||!firstChar&&str[marker]!=' ') {
newStr+=str[marker];
}
vd2d siz; vd2d siz;
if (proportional) { if (proportional) {
siz=GetTextSizeProp(newStr); siz=GetTextSizeProp(newStr);
@ -2639,13 +2642,17 @@ goes on a very long time, I hope you can understand this is only for testing pur
do { do {
if (newStr[newStr.length()-1]!=' ') { if (newStr[newStr.length()-1]!=' ') {
marker--; marker--;
//printf("%s\n",newStr.c_str());
} }
newStr.erase(newStr.end()-1); newStr.erase(newStr.end()-1);
} while (newStr[newStr.length()-1]!=' '); } while (newStr[newStr.length()-1]!=' ');
newStr.erase(newStr.end()-1); //newStr.erase(newStr.end()-1);
newStr+='\n'; newStr+='\n';
firstChar=false;
} else {
firstChar=true;
marker++;
} }
marker++;
} }
return newStr; return newStr;
} }

Loading…
Cancel
Save