ADOBE AFTER EFFECTS: Forum Expressions Tutorials Podcasts Creative Cloud

Paragraph Text Box Control (Reversed)!

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Bilal AlsurriParagraph Text Box Control (Reversed)!
by on Feb 20, 2016 at 7:23:40 pm

is there anyway to make a paragraph text box to be controlled by a shape layer size?

i want to change the shape layer size (rectangle) and this cause the paragraph text box to change accordingly. i searched all the net, and everything there is taking about a shape layer that changes according to the text size using the SourceRectAtTime(), i want the reverse action?


Return to posts index

Kalle KannistoRe: Paragraph Text Box Control (Reversed)!
by on Feb 21, 2016 at 8:05:07 am

I assume you want the text to wrap onto new lines within the shape rectangle?

I don't think you can access the text bounding box, other than reading its value, with expressions.

The only way I can think of doing this (with expressions) is some complicated combination of moving the text box position and adding (and removing) manual line breaks to try and approximate the width of the shape.

Return to posts index

Kalle KannistoRe: Paragraph Text Box Control (Reversed)!
by on Feb 21, 2016 at 11:00:06 am
Last Edited By Kalle Kannisto on Feb 21, 2016 at 11:21:10 am

Here's an attempt at it. It is breaking a paragraph onto lines after a certain number of letters that depends on the width of the rectangle. It's not that accurate, as the number of letters doesn't necessarily correspond to length of line, but it is something. Using this, all text should be the same size and there should be no line breaks in the original source text.

Comp has a rectangle named "Rect" and a text layer that covers the maximum size of the rectangle.

Code for source text:

txt = value;
done = 0;
esc = 0;
len =0;
row = Math.floor(thisComp.layer("Rect").sourceRectAtTime(time).width*thisComp.layer("Rect").scale[0]/1220);//divisor depends on type size
while (done == 0){
esc ++;
if (txt.length >= len+1){
for (i = len; i > len-row; i--) if (txt[i] == " ") break;
if (i > len-row){
txt=txt.substr(0,i) + "\r" + txt.substr(i+1,9999);
len = i;
if (esc>100){done=1}

Return to posts index

Bilal AlsurriRe: Paragraph Text Box Control (Reversed)!
by on Feb 21, 2016 at 9:03:48 pm

Thanks a lot Kalle, appreciate it.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2016 All Rights Reserved