generated from sigonasr2/CPlusPlusProjectTemplate
Fix wrapping text text cut-off
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
8a2db05c36
commit
d706dbe3f2
Binary file not shown.
11
main.cpp
11
main.cpp
@ -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()) {
|
||||||
|
if (firstChar||!firstChar&&str[marker]!=' ') {
|
||||||
newStr+=str[marker];
|
newStr+=str[marker];
|
||||||
|
}
|
||||||
vd2d siz;
|
vd2d siz;
|
||||||
if (proportional) {
|
if (proportional) {
|
||||||
siz=GetTextSizeProp(newStr);
|
siz=GetTextSizeProp(newStr);
|
||||||
@ -2639,14 +2642,18 @@ 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…
x
Reference in New Issue
Block a user