Is it possible to disable word wrapping, without enabling horizontal overflow, when BestFit is turned on?

Is it possible to disable word wrapping, without enabling horizontal overflow, when BestFit is turned on?
So size of the font would be calculated based on the width of Text rather than height.

58288-textbestfitbasedonwidth.png

Since it doesn’t seem possible to disable word wrapping without also enabling overflow, an alternate solution is to replace all spaces in the string with non-breaking spaces. Of course, spaces are not the only characters that can be used to break a word, so this might not work in all use cases.

textComponent.text = textComponent.text.Replace (' ', '\u00A0');

Disable “Best Fit”, Set Vertical OverFlow to “Truncate” and Horizontal Overflow to “Wrap”. Now starting from a small size keep increasing the font size just upto the point where it does not wrap to next line.

Then set the horizontal overflow to “Overflow” [Just to make sure it does not wrap if at all by mistake.].

Then in the ‘Canvas Scaler’ property of the Root Canvas [add if not present], ‘UI scale mode’ to “Scale with screen size”, add the reference resolution you are building for. Set ‘Screen Match Mode’ to “Match width or height” and ‘Match’ to “0.5”[Match height and width proportionally]. The canvas will then be able to scale your text accordingly.

Hope this helps. :slight_smile: