LabelTTF and very long text (about 30000 symbols)

Hi! I need to display very long text about 30000 symbols. But label stop showing the symbols and show empty place. I use cocos2dx 3.16.

auto lbl = Label::createWithTTF(text, "Tahoma.ttf", 55,
                           Size(scroll_view->getContentSize().width*0.9f, 0),
                           TextHAlignment::LEFT, TextVAlignment::CENTER);
lbl->setColor(Color3B(50, 50, 50));
lbl->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
lbl->setPosition(scroll_view->getContentSize().width * 0.05f, hight_inc);
scroll_view->addChild(lbl);

Thank you for your reply.

30,000? What is the use case for this where you can’t display a few at a time?

I using it for displaying stories. I still have this problem.

perhaps divide the string into smaller strings?

Yes, this is an idea, but I want to find out why the Label does not display characters.

Can you send me a test case to try out?

Yes
stories.zip (786.3 KB)

Thanks, let me create a new project and test this out.

Edit: I can get your project to compile, how do I reproduce your issue?

Scroll down until you can see empty place. It must be text not empty place.

I don’t follow


There is no text here, but it must be here

ok, so what is the best way for me to get text and start testing?

Text loads from server
Classes/nfc_core/I18n_Historys.cpp -> void I18n_Historys::loadHistoryOnline(unsigned int h_id)

And callback when loading was finished
Classes/nfc_core/I18n_Historys.cpp -> void I18n_Historys::onHttpHistoryCompleted(cocos2d::network::HttpClient * sender, cocos2d::network::HttpResponse * response)

this condition
else if (std::string(element_child->string) == “h_history”)

Hi. Do you have any news?

I’m not having any test load automatically. So all I see is blank. I’ll just try a new LabelTTF and fill with 30,000 characters from a loop.

I have tested. I inserted 30 000 chars from a loop and got the same problem.

void I18n_Historys::loadHistoryOnline(unsigned int h_id)
{
    _curr_history->text = "";
    for(int i=0; i<30000; i++)
    {
        _curr_history->text = _curr_history->text + "0";
    }
    if(_onHistoryCallback)
        _onHistoryCallback(true);
}

Yup, so I see the same thing. Let’s test how many characters actually do work.

20152 characters.
I have tested this project with cocos2d-x from github and got the same problem.

hmm, lets create a GitHub issue for this. https://github.com/cocos2d/cocos2d-x/issues/18755