Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Number of characters on each line in a paragraph layer

  • Number of characters on each line in a paragraph layer

    Posted by Andrei Popa on May 21, 2021 at 11:04 am

    Hi guys.

    I want to count the number of characters on each line in a paragraph layer. I don’t know if AE has this information in the sourceText property. For now I am thinking about making an animator that makes only one letter visible for each frame from -1 going backward in time. And for each calculate the lowest point via sourceRectAtTime and compare that to the leading or font size or a combination of both. The problem is that this expression will be a bit heavy and I wonder if there is not an easier way that I am not aware of.

    Any suggestion is appreciated. Thanks!

    Andrei Popa replied 4 years, 12 months ago 2 Members · 2 Replies
  • 2 Replies
  • Trent Armstrong

    May 21, 2021 at 2:11 pm

    Andrei,

    Maybe this will get you started. I copied/pasted your text and actually inserted carriage returns at the end of each line. The carriage return—or “\r”—is important to how this expression works. (Maybe someone else knows if AE can read automatic line breaks, but I don’t think it does.) This expression just returns the number of characters per line on the respective line.

    I’m not exactly sure what you’re going for, but this might get you headed in the right direction.

    var txt = text.sourceText.split(“\r”);

    n = txt.length;

    list = [];

    var t = “”;

    for (i=0; i<n; i++) {

    t = txt[i];

    t = t.length;

    list.push(t + “\r”);

    }

    list

    Trent

  • Andrei Popa

    May 22, 2021 at 10:28 am

    Hi Trent. Thanks for the answer. I was not clear enough. My text is a boxText and the linbreaks are the one created by AE. I don’t know of any expression to identify those end of lines, that can be used in .split(). I guess that is kind of what I hoped to exist, an expression to identify those automatic line breaks.

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