-
Reduce source text and add dots to text
I’m looking for a way to actively reduce source text based on input parameter (i.e. shape layer width) and possibly add “…” after reduction.
Lets say starting text is “Test Source” and total width of text layer is 300 px. (sourceRectAtTime()).
Linking it to shape layer that has width of 300 px. When shape layer width is reduced to i.e. 200 px I’d like to output “Test S…” as Text.
I’ve tried with linear, something like this:
rectSize = thisComp.layer(“Shape Layer 1”).content(“Rectangle 1”).content(“Rectangle Path 1”).size[0];
txtLength = text.sourceText.length;
var x = linear(txtLength, 0, txtLength, 0, rectSize);
text.sourceText.slice(0, x/txtLength);
but that doesn’t do the trick, and also doesn’t add three dots at the end.
Also I had an idea to use WHILE loop like this
sizeX=thisComp.layer(“Shape Layer 1”).content(“Rectangle 1”).content(“Rectangle Path 1”).size[0];
widthX=thisLayer.sourceRectAtTime().width;
length=thisLayer.text.sourceText.length;
while(widthX >= sizeX) slice(0,length-1);
Different combinations of while loop ended in error output (infinite loop)
I thought it’s possible to manipulate “boxTextSize” and scale it according to Shape layer size, but I guess that is possible only in scripts (extendScript).
Any direction/advice is much appreciated!