How can I get text to wrap if it is a single, unbroken chain of characters?

So I know how wrapping works with text, in the usual case. Whenever Unreal finds a word that is too long to display fully, it puts it on the next line.

However, for my game I want you to be reading a garbled mess of characters with NO whitespaces. The idea is that the computer data is corrupted. Unfortunately, UMG just puts everything on a single line. The image here shows only one line but there is a lot more text that is not being shown. (See Desired for the effect I’m looking for)

It looks like UMG doesn’t want to wrap because it hasn’t encountered a white space. I want it to wrap and I don’t want to have to edit my text. By the way, this is all in a ScrollBox. It should be wrapping AND showing a scroll bar, but it is not doing either.

I saw this answer (Text Wrap does not affect all text - Feedback & Requests - Epic Developer Community Forums) but unfortunately they resolved it by adding white spaces. I can’t do that if I want an even looking wall of text that works on every resolution.

Let me know how I can solve this, or how I can provide more information. Thank you so much!

(I’m using Blueprint and UMG for this, thanks)

STextBlock actually wraps at points defined by a break iterator, and uses an ICU line-break iterator by default.

The fact that this breaks on things other than just traditional spaces means that you could try injecting zero width space characters into your string at the places that you want it to wrap.

An alternative (that wouldn’t be possible in pure blueprints or UMG) would be to make a custom line-break policy by creating your own break iterator (derived from IBreakIterator) which just marked every character in the string as a potential breaking point. You would then pass this into STextBlock via its LineBreakPolicy argument.

Edit: You don’t actually need to make your own break iterator, as we already have a character boundary iterator available (see FBreakIterator::CreateCharacterBoundaryIterator). This actually breaks on grapheme clusters, but for your use-case, the two can be considered identical :slight_smile:

Thank you so much! I’m only using Blueprint so I have to go in a different direction, but if I come across this with C++ I’ll know what to do. Thanks!