mirror of https://github.com/axmolengine/axmol.git
Fix #1336
This commit is contained in:
parent
012e614d5a
commit
079586d060
|
@ -106,7 +106,6 @@ set(_AX_2D_SRC
|
|||
2d/Grid.cpp
|
||||
2d/LabelAtlas.cpp
|
||||
2d/Label.cpp
|
||||
2d/LabelTextFormatter.cpp
|
||||
2d/Layer.cpp
|
||||
2d/Light.cpp
|
||||
2d/Menu.cpp
|
||||
|
|
|
@ -2854,7 +2854,7 @@ bool Label::multilineTextWrap(const std::function<int(const std::u32string&, int
|
|||
{
|
||||
float newLetterWidth = 0.f;
|
||||
if (_horizontalKernings && letterIndex < textLen - 1)
|
||||
newLetterWidth = static_cast<float>(_horizontalKernings[letterIndex + 1]);
|
||||
newLetterWidth = static_cast<float>(_horizontalKernings[letterIndex + 1]) * _fontScale;
|
||||
newLetterWidth += letterDef.xAdvance * _fontScale + _additionalKerning;
|
||||
|
||||
nextLetterX += newLetterWidth;
|
||||
|
|
|
@ -53,6 +53,28 @@ enum
|
|||
kTagSprite8,
|
||||
};
|
||||
|
||||
class LabelIssue1336 : public AtlasDemoNew
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(LabelIssue1336);
|
||||
|
||||
LabelIssue1336()
|
||||
{
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
TTFConfig config("fonts/arial.ttf");
|
||||
config.distanceFieldEnabled = true;
|
||||
config.faceSize = 72;
|
||||
auto overlapingLabel = Label::createWithTTF(config, "Te");
|
||||
overlapingLabel->setPosition(Vec2(size.width / 2, size.height / 2));
|
||||
overlapingLabel->setColor(ax::Color3B::WHITE);
|
||||
overlapingLabel->setScale(10);
|
||||
addChild(overlapingLabel, 1);
|
||||
}
|
||||
|
||||
virtual std::string title() const override { return "Github Issue 1336"; }
|
||||
virtual std::string subtitle() const override { return "The label char shouldn't overalpping"; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// AtlasDemoNew
|
||||
|
@ -63,6 +85,7 @@ NewLabelTests::NewLabelTests()
|
|||
{
|
||||
ADD_TEST_CASE(LabelOutlineAndGlowTest);
|
||||
ADD_TEST_CASE(LabelTTFDistanceField);
|
||||
ADD_TEST_CASE(LabelIssue1336);
|
||||
ADD_TEST_CASE(LabelIssue20523);
|
||||
ADD_TEST_CASE(LabelFNTGlyphDesigner);
|
||||
ADD_TEST_CASE(LabelFNTColor);
|
||||
|
@ -1116,8 +1139,7 @@ LabelTTFCJKWrappingTest::LabelTTFCJKWrappingTest()
|
|||
Color4F(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
TTFConfig ttfConfig("fonts/HKYuanMini.ttf", 25, GlyphCollection::DYNAMIC);
|
||||
auto label1 =
|
||||
Label::createWithTTF(ttfConfig, "你好,Axmol Label.", TextHAlignment::LEFT, size.width * 0.75f);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "你好,Axmol Label.", TextHAlignment::LEFT, size.width * 0.75f);
|
||||
if (label1)
|
||||
{
|
||||
label1->setTextColor(Color4B(128, 255, 255, 255));
|
||||
|
@ -1130,8 +1152,7 @@ LabelTTFCJKWrappingTest::LabelTTFCJKWrappingTest()
|
|||
label1->setTTFConfig(ttfConfig);
|
||||
}
|
||||
|
||||
auto label2 =
|
||||
Label::createWithTTF(ttfConfig, "早上好,Axmol Label.", TextHAlignment::LEFT, size.width * 0.75f);
|
||||
auto label2 = Label::createWithTTF(ttfConfig, "早上好,Axmol Label.", TextHAlignment::LEFT, size.width * 0.75f);
|
||||
if (label2)
|
||||
{
|
||||
label2->setTextColor(Color4B(255, 128, 255, 255));
|
||||
|
|
Loading…
Reference in New Issue