mirror of https://github.com/axmolengine/axmol.git
commit
564918c604
|
@ -591,10 +591,6 @@ void Label::alignText()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& batchNode:_batchNodes)
|
|
||||||
{
|
|
||||||
batchNode->getTextureAtlas()->removeAllQuads();
|
|
||||||
}
|
|
||||||
_fontAtlas->prepareLetterDefinitions(_currentUTF16String);
|
_fontAtlas->prepareLetterDefinitions(_currentUTF16String);
|
||||||
auto& textures = _fontAtlas->getTextures();
|
auto& textures = _fontAtlas->getTextures();
|
||||||
if (textures.size() > _batchNodes.size())
|
if (textures.size() > _batchNodes.size())
|
||||||
|
@ -615,31 +611,45 @@ void Label::alignText()
|
||||||
if(_labelWidth > 0 || (_currNumLines > 1 && _hAlignment != TextHAlignment::LEFT))
|
if(_labelWidth > 0 || (_currNumLines > 1 && _hAlignment != TextHAlignment::LEFT))
|
||||||
LabelTextFormatter::alignText(this);
|
LabelTextFormatter::alignText(this);
|
||||||
|
|
||||||
int strLen = static_cast<int>(_currentUTF16String.length());
|
if (!_children.empty())
|
||||||
Rect uvRect;
|
{
|
||||||
Sprite* letterSprite;
|
int strLen = static_cast<int>(_currentUTF16String.length());
|
||||||
for(const auto &child : _children) {
|
Rect uvRect;
|
||||||
int tag = child->getTag();
|
Sprite* letterSprite;
|
||||||
if(tag >= strLen)
|
for (auto index = 0; index < _children.size();) {
|
||||||
{
|
auto child = _children.at(index);
|
||||||
SpriteBatchNode::removeChild(child, true);
|
int tag = child->getTag();
|
||||||
}
|
if (tag >= strLen)
|
||||||
else if(tag >= 0)
|
|
||||||
{
|
|
||||||
letterSprite = dynamic_cast<Sprite*>(child);
|
|
||||||
if (letterSprite)
|
|
||||||
{
|
{
|
||||||
uvRect.size.height = _lettersInfo[tag].def.height;
|
SpriteBatchNode::removeChild(child, true);
|
||||||
uvRect.size.width = _lettersInfo[tag].def.width;
|
}
|
||||||
uvRect.origin.x = _lettersInfo[tag].def.U;
|
else if (tag >= 0)
|
||||||
uvRect.origin.y = _lettersInfo[tag].def.V;
|
{
|
||||||
|
letterSprite = dynamic_cast<Sprite*>(child);
|
||||||
|
if (letterSprite)
|
||||||
|
{
|
||||||
|
uvRect.size.height = _lettersInfo[tag].def.height;
|
||||||
|
uvRect.size.width = _lettersInfo[tag].def.width;
|
||||||
|
uvRect.origin.x = _lettersInfo[tag].def.U;
|
||||||
|
uvRect.origin.y = _lettersInfo[tag].def.V;
|
||||||
|
|
||||||
letterSprite->setTexture(textures.at(_lettersInfo[tag].def.textureID));
|
letterSprite->setTexture(textures.at(_lettersInfo[tag].def.textureID));
|
||||||
letterSprite->setTextureRect(uvRect);
|
letterSprite->setTextureRect(uvRect);
|
||||||
|
}
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& batchNode : _batchNodes)
|
||||||
|
{
|
||||||
|
batchNode->getTextureAtlas()->removeAllQuads();
|
||||||
|
}
|
||||||
|
|
||||||
updateQuads();
|
updateQuads();
|
||||||
|
|
||||||
updateColor();
|
updateColor();
|
||||||
|
|
|
@ -75,6 +75,7 @@ NewLabelTests::NewLabelTests()
|
||||||
ADD_TEST_CASE(LabelSmallDimensionsTest);
|
ADD_TEST_CASE(LabelSmallDimensionsTest);
|
||||||
ADD_TEST_CASE(LabelIssue10089Test);
|
ADD_TEST_CASE(LabelIssue10089Test);
|
||||||
ADD_TEST_CASE(LabelSystemFontColor);
|
ADD_TEST_CASE(LabelSystemFontColor);
|
||||||
|
ADD_TEST_CASE(LabelIssue10773Test);
|
||||||
};
|
};
|
||||||
|
|
||||||
LabelTTFAlignmentNew::LabelTTFAlignmentNew()
|
LabelTTFAlignmentNew::LabelTTFAlignmentNew()
|
||||||
|
@ -1862,3 +1863,24 @@ std::string LabelSystemFontColor::subtitle() const
|
||||||
{
|
{
|
||||||
return "Testing text color of system font";
|
return "Testing text color of system font";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LabelIssue10773Test::LabelIssue10773Test()
|
||||||
|
{
|
||||||
|
auto center = VisibleRect::center();
|
||||||
|
|
||||||
|
auto label = Label::createWithTTF("create label with TTF", "fonts/arial.ttf", 24);
|
||||||
|
label->getLetter(5);
|
||||||
|
label->setString("Hi");
|
||||||
|
label->setPosition(center.x, center.y);
|
||||||
|
addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LabelIssue10773Test::title() const
|
||||||
|
{
|
||||||
|
return "Test for Issue #10773";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LabelIssue10773Test::subtitle() const
|
||||||
|
{
|
||||||
|
return "Should not crash!";
|
||||||
|
}
|
||||||
|
|
|
@ -554,4 +554,15 @@ public:
|
||||||
virtual std::string subtitle() const override;
|
virtual std::string subtitle() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LabelIssue10773Test : public AtlasDemoNew
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CREATE_FUNC(LabelIssue10773Test);
|
||||||
|
|
||||||
|
LabelIssue10773Test();
|
||||||
|
|
||||||
|
virtual std::string title() const override;
|
||||||
|
virtual std::string subtitle() const override;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue