Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Auto-scale a text line in a multi-line text layer

  • Auto-scale a text line in a multi-line text layer

    Posted by Benjamin Letellier on May 23, 2021 at 3:41 am

    Hello,

    I have an issue and I wonder if you could help me.
    I’ll try to explain, my English is not perfect sorry.

    I have a text layer with 5 lines. By line I mean I hit enter 4 times :

    Bla bla bla bla bla
    bla bla bla
    bla bla bla bla bla bla bla
    bla bla bla
    bla.

    I need to scale each line to have a nice alignement.
    I succeed to do that with five text layer and the expression SourceRecAtTime() combined to the scale of the layer 2-3-4 and 5. The number 1 being my master.

    But now I need to have only one text layer (easier to use for my journalists)… but still 5 lines and the nice alignement.
    So I precomposed my text five times and extract each line. From now I can scale each line (and auto move on Y axis) to have a nice result.

    But if I want to do it automatically, I need to know which height is doing each line.
    And now is my problem.
    How to do a SourceRecAtTime() on just one line ?
    I tried and tried to duplicate my text and to subtract the line I need to measure it.
    Unsuccessfully…

    If anyone has an idea.
    Thank you.

    Julian Chojnacki replied 3 years, 6 months ago 3 Members · 5 Replies
  • 5 Replies
  • Kevin Camp

    May 24, 2021 at 8:30 pm

    I think I’d keep your five separate text layers (one for each line), but link their sourceTexts to a master text layer that the journalists would use to enter text.

    I’d parent each of the separate lines to the master and hide the master (or set opacity to zero), then do a split expression to separate the lines:

    txt = parent.text.sourceText ;
    lines = txt.split('\r') ;
    lines[0] // change 0 to 1, 2, 3, or 4 depending which line of text you want
  • Benjamin Letellier

    May 25, 2021 at 5:17 pm

    Hello Kevin,

    Thanks a lot for yours response.

    I’ll try that asap and tell you if I succeed.

    Benjamin

     

  • Benjamin Letellier

    May 25, 2021 at 5:17 pm

    Hello again,

    It works perfectly fine !

    Thanks again Kevin !

  • Julian Chojnacki

    November 8, 2022 at 11:06 am

    Hi Benjamin (& Kevin),

    I know this is late, but you could also use text animators to adjust the scaling based on lines in order to keep everything on a single layer.

    For full control, use a text animator for each line and separate them with range selectors, then adjust the scaling individually.

    A quicker way is using a single text animator with randomized order and the shape you want (square won’t work unless you tweak the Start or End range), then use the random seed to adjust the result. Which might get a little fiddly, though.

    Notice that you’ll need to set the text layer’s anchor point grouping to “Line” first and to add the line spacing property to the text animators to compensate for the misaligned leading due to the scaling.

  • Julian Chojnacki

    November 8, 2022 at 2:07 pm

    Just realizing that my approach is everything but “auto” and doesn’t really fit the thread, lol… I still do hope that anyone who stumbles upon this like me, trying to replicate something similar to Instagram’s auto captions (without the need to scale every line manually), gets some value out of it.

    @kevincamp your solution is spot on.

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