Copy link to clipboard
Copied
I know you can explicitly set a space to "no break" using the character palette, but I need to set non-breaking spaces using expressions. Problem is, it sure looks like AE just treats non-breaking spaces like regular old spaces and breaks on them anyway when laying out paragraph text. Is there a simple solution to this, a setting I'm missing maybe? I can work around it with a character value animator, but it doesn't seem like this should be needed, right?
Copy link to clipboard
Copied
It looks like After Effects doesn't tag the space, but instead tags the two words either side of the non-breaking space. I took a quick look, but can't spot what that tag is via expressions.
When I made my tutorial for resizing a text box, I denoted line breaks with the '|' symbol and then replaced them after my code with line breaks. So my text midway looked like "the|Quick|brown|fox|jumps|over|the|lazy|dog. This gave me a bit more control.
Depending what you're trying to do with your expression, could you start by splitting the text into an array and adding a different symbol at the point where you want a non-breaking space?
This code below splits the text by spaces and reassembles it, but adds in a symbol after the 4th word instead of a space.
var myArray = text.sourceText.split(' ');
txt = '';
for (var i = 0; i< myArray.length; i++) {
txt += myArray[i];
if (i == 4) {
txt += '|';
} else {
txt += ' ';
}
}
txt;
Copy link to clipboard
Copied
Yeah, I have been doing something similar, except uisng a regular expression and the replace() function to insert a placeholder character, then changing it back to a space with a text animator. It's just annoying that it has to be this complicated.