ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Is it possible to make a Infinite text box?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Lucas Pereira
Is it possible to make a Infinite text box?
on Oct 31, 2019 at 12:57:05 pm

Hi! I'm a art director, and I'm very new to the expressions world, but I'm currently working with creation of after effects templates. I stumbled on a design problem, that is the amount of text a person can fill in a text box. Sometimes the textbox cuts the sentences because it doesn't fit the clients text.

However, I need to keep the design, so I can't just make a bigger textbox. Is it possible to make a textbox that decreases the font size accordingly to the text length? So the client can fill it with whatever text he/she wants? I tried a lot of expressions I've seen online but none worked for me.

Thanks.


Return to posts index

Andrei Popa
Re: Is it possible to make a Infinite text box?
on Nov 2, 2019 at 7:23:10 am

You can't do that with textboxes. Expressions can't change font size or textBox bounds.

Some workaround would be to make your text a textPoint paragraph and the client would have to insert the newlines, since the textPoint does not break the text.

Then you could add an expression to the size, so this layer decreases when there is more text.

Andrei
My Envato portfolio.


Return to posts index

Lucas Pereira
Re: Is it possible to make a Infinite text box?
on Nov 4, 2019 at 12:25:42 pm

I've never used textPoint before. Our clients fill kind of a form with the texts they want and the platform translates that to AE. Would that way work with textPoint?


Return to posts index


Tomas Bumbulevičius
Re: Is it possible to make a Infinite text box?
on Nov 2, 2019 at 9:02:25 am

Hey Lucas, it really depends on the amount of text in a placeholder you/client needs to fit in.

If its relatively not much longer than full sized phrase, then it could be scaled down with expression. However, it content might be significantly more longer, then completely different approaches can be applied.

Please share most common example in action and we could provide more generic approach to suit more than a single case.

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

Lucas Pereira
Re: Is it possible to make a Infinite text box?
on Nov 4, 2019 at 12:37:36 pm

Thank you Tomas!

We're right now limiting the client around 50 or 150 chars as maximum lenght at our platform, but even this way, some text boxes cut the text. If we could estipulate 200 or even 300 as a max number it would be perfect. From our early tests, it would rarelly get to that length.

For example, in this image the textbox is 30 chars long, but is a hotel template. The client might want to put more information about the rooms price. Maybe 50/60 chars?



Return to posts index

Tomas Bumbulevičius
Re: Is it possible to make a Infinite text box?
on Nov 5, 2019 at 9:26:23 am

Lucas, in the example above - would you prefer that text remains in 3 lines, just scales down, OR, increase number of lines?

Also, is it a concern for you how that blue line aligns? Does it need to follow the text above, or is it already responsive?

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index


Lucas Pereira
Re: Is it possible to make a Infinite text box?
on Nov 5, 2019 at 2:16:50 pm

Hey Tomas, thanks for the reply again.
I guess it could have more lines but ocuppying the same amount of space so the design won't get ruined. Sorry, I don't know if I'm being clear, this is all new to me haha.

The blue line is already responsive to the textbox height. ( very proud of myself on this one haha)

Thanks again.


Return to posts index

Tomas Bumbulevičius
Re: Is it possible to make a Infinite text box?
on Nov 7, 2019 at 11:39:24 am

Lucas, try this one below. The splitter function I had in my library developed by someone else. Adding random phrase of text will split into different lines. Plain text layer works (No area text is required), no rescalling will be introduced either.

Define your layer in textSource, and charsPerLine number. This is pretty much it, but some super long words are cutted, Maybe someone could improve it based on this example.

Keep the line dynamic by linking its Y position to the height of the text.

textSource = thisComp.layer(3).text.sourceText;
charsPerLine = 30;

function splitter(str, l){
var strs = [];
while(str.length > l){
var pos = str.substring(0, l).lastIndexOf(' ');
pos = pos &lt;= 0 ? l : pos;
strs.push(str.substring(0, pos));
var i = str.indexOf(' ', pos)+1;
if(i &lt; pos || i > pos+l)
i = pos;
str = str.substring(i);
}
strs.push(str);
return strs.toString();
}

outputString = splitter(textSource, charsPerLine);
numLines = outputString.split(",").length;
res = "";


for (var j=0; j<numLines; j++){
res = res + outputString.split(",")[j] + "\n";
}
res


Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

Lucas Pereira
Re: Is it possible to make a Infinite text box?
on Nov 7, 2019 at 5:42:23 pm

Wow, thanks for the help Tomas! I don't know why, when I pasted the expression, it keeps giving me error " SyntaxError: Unexpected token = "
I already tried to fix it but couldn't make it work, even deleting some parts, it keeps giving me this error.

Me and a friend came up with a expression that also worked, but it only resizes the text. When we use it, we can't pull the text from another layer like we should be able to. We can't link the sourceText to a layer on the "Data" comp like I explained before, After Effects seems to just ignore if we try.

The expression we came up with was this one:

minSize = 100;
maxSize = 10;
factor = 1.5;
l = thisLayer.text.sourceText.length;
size = Math.max(minSize, maxSize - (l / factor));
style.setFontSize(size);


Return to posts index


Tomas Bumbulevičius
Re: Is it possible to make a Infinite text box?
on Nov 7, 2019 at 8:11:59 pm

Lucas, there are some syntax handlers here. Please check for the reference this image.



Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]