mirror of https://github.com/axmolengine/axmol.git
fix endless loop when dimensions that are not enough to fit one character
This commit is contained in:
parent
442f767c89
commit
8ea473de7b
|
@ -151,16 +151,20 @@ bool LabelTextFormatter::multilineText(Label *theLabel)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringUtils::trimUTF16Vector(last_word);
|
StringUtils::trimUTF16Vector(last_word);
|
||||||
|
if (isStartOfLine)
|
||||||
|
last_word.push_back(character);
|
||||||
|
|
||||||
last_word.push_back('\n');
|
last_word.push_back('\n');
|
||||||
|
|
||||||
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
|
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
|
||||||
last_word.clear();
|
last_word.clear();
|
||||||
|
if (!isStartOfLine)
|
||||||
|
--j;
|
||||||
|
|
||||||
isStartOfWord = false;
|
isStartOfWord = false;
|
||||||
isStartOfLine = false;
|
isStartOfLine = false;
|
||||||
startOfWord = -1;
|
startOfWord = -1;
|
||||||
startOfLine = -1;
|
startOfLine = -1;
|
||||||
--j;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -80,7 +80,8 @@ static std::function<Layer*()> createFunctions[] =
|
||||||
CL(LabelIssue4428Test),
|
CL(LabelIssue4428Test),
|
||||||
CL(LabelIssue4999Test),
|
CL(LabelIssue4999Test),
|
||||||
CL(LabelLineHeightTest),
|
CL(LabelLineHeightTest),
|
||||||
CL(LabelAdditionalKerningTest)
|
CL(LabelAdditionalKerningTest),
|
||||||
|
CL(LabelIssue8492Test)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
||||||
|
@ -1814,3 +1815,21 @@ std::string LabelAdditionalKerningTest::subtitle() const
|
||||||
{
|
{
|
||||||
return "Testing additional kerning of label";
|
return "Testing additional kerning of label";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LabelIssue8492Test::LabelIssue8492Test()
|
||||||
|
{
|
||||||
|
auto label = Label::createWithBMFont("fonts/bitmapFontChinese.fnt", "中国中国中国中国中国");
|
||||||
|
label->setDimensions(5,100);
|
||||||
|
label->setPosition(VisibleRect::center());
|
||||||
|
addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LabelIssue8492Test::title() const
|
||||||
|
{
|
||||||
|
return "Reorder issue #8492";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LabelIssue8492Test::subtitle() const
|
||||||
|
{
|
||||||
|
return "Work fine when dimensions are not enough to fit one character";
|
||||||
|
}
|
||||||
|
|
|
@ -509,6 +509,17 @@ private:
|
||||||
Label* label;
|
Label* label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LabelIssue8492Test : public AtlasDemoNew
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CREATE_FUNC(LabelIssue8492Test);
|
||||||
|
|
||||||
|
LabelIssue8492Test();
|
||||||
|
|
||||||
|
virtual std::string title() const override;
|
||||||
|
virtual std::string subtitle() const override;
|
||||||
|
};
|
||||||
|
|
||||||
// we don't support linebreak mode
|
// we don't support linebreak mode
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue