Label overflow not clamping text

Hi there

Using Cocos2dx-3.10

Hopefully a trivial one but can’t work it out…

How do i constrain a labels text to it’s contentSize?

Example:

auto usernameLabel = Label::createWithTTF(item->username, "fonts/WhitneyMedium.ttf", 8.0);
    usernameLabel->setPosition(Vec2(0, cell->getContentSize().height/2));
    usernameLabel->setContentSize(Size(20, usernameLabel->getContentSize().height));
    usernameLabel->setOverflow(cocos2d::Label::Overflow::CLAMP);

This doesn’t “clamp” the text. Ideally i’d like ellipsis but i’ll settle for it just clipping the text at the moment.

Thanks!

I was using setContentSize() thinking that would constrain the size but infact you need to use setWidth()

Not sure how i missed that!!