-
Finding the number of lines in a block of paragraph text
I’m trying to write an expression that resizes a shape layer depending on the size of a paragraph text layer.
I could just use sourceRectAtTime() *but* if there’s only one line, I want to size the box to the width of the text. If it runs over two or more lines, the box should be a fixed (maximum) width. With non-paragraph text you can just count the number of carriage returns –
L = thisComp.layer("text_layer");
tx = L.text.sourceText.valueAtTime(time);
h = tx.split('\r');
n = h.length; // how many lines we've got
But I can’t think of a way to interrogate the paragraph text layer to find out how many lines it’s running to. Is there one, or will this be a case of manually keyframing?