mirror of https://github.com/axmolengine/axmol.git
Merge pull request #9904 from Dhilan007/v3-systemfont-android-fix
Fixed dead loop when the width of label[system font] smaller then one word of the string on android
This commit is contained in:
commit
c1b958c540
|
@ -384,7 +384,7 @@ public class Cocos2dxBitmap {
|
||||||
i = lastIndexOfSpace + 1; // skip space
|
i = lastIndexOfSpace + 1; // skip space
|
||||||
} else {
|
} else {
|
||||||
// Should not exceed the width.
|
// Should not exceed the width.
|
||||||
if (tempWidth > maxWidth) {
|
if (tempWidth > maxWidth && i != start + 1) {
|
||||||
strList.add(string.substring(start, i - 1));
|
strList.add(string.substring(start, i - 1));
|
||||||
// Compute from previous char.
|
// Compute from previous char.
|
||||||
--i;
|
--i;
|
||||||
|
|
|
@ -83,7 +83,8 @@ static std::function<Layer*()> createFunctions[] =
|
||||||
CL(LabelAdditionalKerningTest),
|
CL(LabelAdditionalKerningTest),
|
||||||
CL(LabelIssue8492Test),
|
CL(LabelIssue8492Test),
|
||||||
CL(LabelMultilineWithOutline),
|
CL(LabelMultilineWithOutline),
|
||||||
CL(LabelIssue9255Test)
|
CL(LabelIssue9255Test),
|
||||||
|
CL(LabelSmallDimensionsTest)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
||||||
|
@ -1877,3 +1878,20 @@ std::string LabelIssue9255Test::subtitle() const
|
||||||
{
|
{
|
||||||
return "switch to desktop and switch back. Crashed!!!";
|
return "switch to desktop and switch back. Crashed!!!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LabelSmallDimensionsTest::LabelSmallDimensionsTest()
|
||||||
|
{
|
||||||
|
auto label = Label::createWithSystemFont("Hello World!", "fonts/arial.ttf", 24, Size(30,100));
|
||||||
|
label->setPosition(VisibleRect::center());
|
||||||
|
addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LabelSmallDimensionsTest::title() const
|
||||||
|
{
|
||||||
|
return "Test create Label[system font] with small dimensions";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LabelSmallDimensionsTest::subtitle() const
|
||||||
|
{
|
||||||
|
return "Program should not dead loop";
|
||||||
|
}
|
||||||
|
|
|
@ -544,5 +544,16 @@ public:
|
||||||
virtual std::string subtitle() const override;
|
virtual std::string subtitle() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LabelSmallDimensionsTest : public AtlasDemoNew
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CREATE_FUNC(LabelSmallDimensionsTest);
|
||||||
|
|
||||||
|
LabelSmallDimensionsTest();
|
||||||
|
|
||||||
|
virtual std::string title() const override;
|
||||||
|
virtual std::string subtitle() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue