Safe to modify FText?

I’ve been working on a word wrapping system that attempts to fit FText into a bubble on the screen (The built in word wrap won’t suit my needs). It’s converted to an FString to break up and check if it fits inside a maximum size. If it doesn’t then it’s split into an array of FString that all fit within the bubble. When there is no text left it’s then put back together with the LINE_TERMINATOR between each line and then sent to be displayed on the screen. It appears to still work with multiple languages but I worry given the amount of warnings about potential loss of data that it isn’t safe to do it this way but wanted to confirm it first before looking at alternatives.

You’ll break live-culture switching by modifying the text in this way, but other than that it should be okay.

Note that you’ll want to be wary of breaking the text at inappropriate points, and should use a line-break iterator (FBreakIterator::CreateLineBreakIterator) to get potential breaking points that work for all languages.

The wrapping method you describe sounds like our default wrapping. What’s special about yours? (non-square shape?)

Thanks Jamie, so essentially I should just run the process again if I had a live culture change? I’ll look into the FBreakIterator as that has been on my mind too.

Yeah, if you still have the source FText you could use an FTextSnapshot to detect when it changes (this would require a Tick, see how it’s used in our Slate widgets for an example).