Activity › Forums › Adobe After Effects Expressions › Is it possible to make a Infinite text box?
-
Is it possible to make a Infinite text box?
Posted by Lucas Pereira on October 31, 2019 at 12:57 pmHi! 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.
Tomas Bumbulevičius replied 6 years, 10 months ago 3 Members · 9 Replies -
9 Replies
-
Andrei Popa
November 2, 2019 at 7:23 amYou 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. -
Tomas Bumbulevičius
November 2, 2019 at 9:02 amHey 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 -
Lucas Pereira
November 4, 2019 at 12:25 pmI’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?
-
Lucas Pereira
November 4, 2019 at 12:37 pmThank 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?
-
Tomas Bumbulevičius
November 5, 2019 at 9:26 amLucas, 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 -
Lucas Pereira
November 5, 2019 at 2:16 pmHey 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.
-
Tomas Bumbulevičius
November 7, 2019 at 11:39 amLucas, 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 <= 0 ? l : pos;
strs.push(str.substring(0, pos));
var i = str.indexOf(' ', pos)+1;
if(i < 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";
}
resFind out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer – Dynamic Text Boxes Template with a Live Preview -
Lucas Pereira
November 7, 2019 at 5:42 pmWow, 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); -
Tomas Bumbulevičius
November 7, 2019 at 8:11 pmLucas, 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
Reply to this Discussion! Login or Sign Up

