Hello, I noticed that ColibriManger doesn't resize the font for the label class when updateDerivedTransformOnly() is called.
Should setDefaultFontSize() be called as well? This seems like the intended behavior.
Hello, I noticed that ColibriManger doesn't resize the font for the label class when updateDerivedTransformOnly() is called.
Should setDefaultFontSize() be called as well? This seems like the intended behavior.
Hi.
Intended behavior is for the font size to remain constant.
Label's size (via setSize) affects clipping, text wrapping, and left/center/right text alignment (and also top/center/bottom).
Thus indeed if you want the text to shrink or grow, you can call Label::setDefaultFontSize. The most common pattern is:
Code: Select all
label->setDefaultFontSize( colibriManager->getDefaultFontSize26d6() * 30u / 16u ); // Set the font to 1.875x te global default font size
label->setText( "Hello World" );
label->sizeToFit();
The use of colibriManager->getDefaultFontSize26d6
is not mandatory, but it is very convenient because that way you can easily implement accessibility options to shrink/grow all text from one place while preserving proportions: simply call colibriManager->setDefaultFontSize26d6 in the options menu presented to the user, and all labels created afterwards will be using the new size (existing labels won't be modified unless you go through them and manually update and re-layout them).
Like this:
Thanks for clearing that up!
If anyone else has this problem, my solution is:
Add a function to access the labelVec in ColibriManager.
Iterate through the labels and set the font size whenever my app's window changes size.
Since the canvas size stays constant, font size is changed based on the window's resolution.
If you want different font sizes for different labels, assign each label a specific m_userId and then check the IDs when iterating through them