Activity › Forums › Adobe After Effects Expressions › space symbol ” ” in Ae expressions
-
space symbol ” ” in Ae expressions
Posted by Alex Andry on January 20, 2021 at 8:26 amHi guys, I’m trying to repeat the text along path, but the end of the text and the beginning are connected without a space ” “. If I put “. “, then the break (space) after dot works. Is there a way to make a break without a dot, just a space.
txt = thisComp.layer(“source”).text.sourceText+” “;
num= 10 ;
xRepeater = num;
horzRepeat = ” “+txt.repeat(xRepeater); // does not work
horzRepeat = “. “+txt.repeat(xRepeater); // space works after dot
Thanks in advance!
Alex Andry replied 5 years, 3 months ago 2 Members · 8 Replies -
8 Replies
-
Filip Vandueren
January 20, 2021 at 9:34 amYou could add 1 character that has the same width as the space (could be “-“ or “_” or “m”, whatever; it depends on the font and you can experiment to find the best one.).
And then use a text animator to select just that 1 character and set its opacity to 0
-
Alex Andry
January 20, 2021 at 10:12 amHi Filip,
Of course, I did this, added a “symbol” and made it transparent in the animator. But in any case, these are crutches for expression. Distance between words will constantly change due to repeaters, and the width of the “symbol” will not. During the cyclic animation along path (I have previously indicated to calculate the length of the path), this discrepancy is visible.I was hoping that in newer versions of Ae it is possible to put a space.
thanks for your reply
-
Filip Vandueren
January 20, 2021 at 11:02 amRight, I understand better now.
Is it always 1 word that is repeated or a sentence of different words ?
-
Alex Andry
January 20, 2021 at 11:26 amThe number of repeats will change depending on the length of the text with the slider. The shorter the text, the more repeats. But with these changes, the gap between repetitions changes. The space is always different in this case, since Force Alignment is enabled.
-
Filip Vandueren
January 20, 2021 at 1:06 pmOK, this works:
txt = text.sourceText+" \u200B";
txt.repeat(10);Unicode character 200B is a zero-width space, after the regular space, it doesn’t interfere with anything in the middle repeats, and it fixes the final margin.
-
Filip Vandueren
January 20, 2021 at 1:48 pmBonus:
If you have your original Text in another Layer, you can automatically calculate the optimal number of repeats by dividing the approximate length of the Path by the width of the original Text.
Like this:
originalTxt = thisComp.layer("Original Text").text.sourceText;
txt = originalTxt.value+" \u200B";
w = thisComp.layer("Original Text").sourceRectAtTime().width;
// get approximate length of path
l = 0;
precision = 10;
txtPath = mask(text.pathOption.path.toString()).maskPath;
p0=txtPath.pointOnPath(0, t = time);
for (i=1; i<=precision; i++) {
p1 = txtPath.pointOnPath(i/precision, t = time)
l+=length(p0, p1);
p0=p1;
}
repeats = Math.max(1,Math.floor(l/w));
style = originalTxt.style; // make sure we also get formatting of original text
style.setText(txt.repeat(repeats));See an example here:
-
Alex Andry
January 20, 2021 at 2:15 pmBonus??? It is fantastic!!! Part of this expression also calculated the path length in my expression for animation, but I used this parameter for animation only. You have made a very elegant expression without extra controllers. I am grateful to you Filip!
Reply to this Discussion! Login or Sign Up