Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Text Layer Scale Based on Amount of Characters

  • Text Layer Scale Based on Amount of Characters

    Posted by Thomas Hardy on July 27, 2011 at 12:12 am

    Let’s say I have a text layer with 25 characters and another text layer with 10 characters.

    I want both using the same amount of space in the composition automatically so I don’t need to adjust every time the text (I have to render a lot of times the same composition with different texts), the only thing I can think about is scale the text layers based on the amount of characters, any idea how to do this with expressions or scripts?

    Thomas Hardy.-
    Newbie and Learning.

    Thomas Hardy replied 14 years, 9 months ago 2 Members · 11 Replies
  • 11 Replies
  • Dan Ebberts

    July 27, 2011 at 12:31 am

    You could try something like this for the layer’s scale:

    [12/text.sourceText.length*100,value[1]]

    Change the 12 to the number of characters you want for a line scaled to 100%. It won’t be real accurate unless you use a mono-spaced font, but it might be close enough.

    Dan

  • Thomas Hardy

    July 27, 2011 at 1:11 am

    Thank you so much, but it scales only the width, not the height.

    Any ideas how to fix that?

    Thomas Hardy.-
    Newbie and Learning.

  • Dan Ebberts

    July 27, 2011 at 1:59 am

    s = 12/text.sourceText.length*100;
    [s,s]

    Dan

  • Thomas Hardy

    July 27, 2011 at 2:06 am

    Amazing! Thanks!

    Where are you reading about expressions !? I can’t find any good guide or doc.

    Thomas Hardy.-
    Newbie and Learning.

  • Thomas Hardy

    July 27, 2011 at 8:31 am

    Ok, now I understand a bit how it works, but I’m trying to so something that I don’t know if possible and I can’t find any list of “commands” or something.

    Can I assign different values to scale depending on the amount of characters?

    I mean, something like

    if text.characters = 10 then
    [100,100]

    if text.characters = 11 then
    [90,90]

    if text.characters = 12 then
    [80,80]

    if text.characters = 13 then
    [70,70]

    if text.characters = 14 then
    [60,60]

    if text.characters = 15 then
    [50,50]

    Is this possible with expressions?

    Thomas Hardy.-
    Newbie and Learning.

  • Dan Ebberts

    July 27, 2011 at 1:15 pm

    Like this:

    s = (20 – text.sourceText.length)*10;
    [s,s]

    Dan

  • Thomas Hardy

    July 27, 2011 at 9:51 pm

    Nop, that’s the same but using only a 10% scale with 20 chars.

    What I need is specify a scale for each character value.

    If 20 characters written then 100% scale
    If 18 characters written then 95% scale
    If 16 characters wtitten then 90% scale

    etc…

    Thomas Hardy.-
    Newbie and Learning.

  • Dan Ebberts

    July 27, 2011 at 10:40 pm

    Well, I’m confused because last time you said 10 characters at 100%, but this gives the 20 at 100% progression:

    s = 50 + text.sourceText.length*2.5;
    [s,s]

    If that’s not it, I’m really clueless.

    Dan

  • Thomas Hardy

    July 28, 2011 at 6:09 am

    I will explain, let’s say I have a red rectangle

    https://imageshack.us/photo/my-images/695/screen1xx.jpg/

    This rectangle is the allowed margin for the text, any partial text out of this rectangle looks bad.

    Now, this looks ok:

    https://imageshack.us/photo/my-images/20/screen2nc.jpg/

    If I use this expression:

    s = 12/text.sourceText.length*100;
    [s,s]

    When I have less than 5 characters the size is HUGE and out of margin, it must be centered in the rectangle even if only 1, 2, 3 or 5 characters too.

    https://www.youtube.com/watch?v=GDIBK2uYcx4

    I want it to look like this:

    https://imageshack.us/photo/my-images/811/screen4q.jpg/

    Thomas Hardy.-
    Newbie and Learning.

  • Dan Ebberts

    July 28, 2011 at 1:46 pm

    Something like this, maybe:

    s = 12/Math.max(text.sourceText.length,6)*100;
    [s,s]

    Dan

Page 1 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy