Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Find out position of individual characters in text layer

  • Find out position of individual characters in text layer

    Posted by Tilman Commes on January 9, 2021 at 4:18 pm

    Hi!
    I would like to enable the people who use my .aep to visually position two guide-layers on a text layer, to choose a text range to be highlighted.
    Therefore, I would have to inquire the position of individual letters and their index inside the text string. Is that possible? Or does anybody have an idea for a workaround?
    Thanks!

    Filip Vandueren replied 5 years, 3 months ago 4 Members · 7 Replies
  • 7 Replies
  • Andrei Popa

    January 12, 2021 at 8:19 am

    I don’t think what you want is possible. The best way I can think of to do that would be to put a point control or 2 sliders on the text, and those 2 values would be the start character index/end character index of the highlight part.

    If you want to make this graphically visible with guide layers, I think you could put 2 squares or something at the top of the composition and get the indexes based on those 2 layers x-position. Basically, like a volume bar, but to control those values. You can divide the x position by 10 or something like that to make it easier to control(kind of lowering the sensitivity).

    You can also add an expression like the following one to those 2 layers to make sure they stay fixed on the y axis.

    yVal = 100;//200 for the other one

    [value[0],yVal]

  • Filip Vandueren

    January 13, 2021 at 9:52 am

    Possible, but not in a very straightforward way.

    Is the textlayer always just 1 line, Or could it sometimes be multiple lines ? Is it a paragraph text or a box-text ?

    The actual highlighting is done with a text-animator ?

  • Filip Vandueren

    January 13, 2021 at 11:54 am
  • Tilman Commes

    January 13, 2021 at 12:04 pm

    Wow, thanks a lot Filip! I will take this project apart for educational purposes if I may!

    No, the text layer can have different numbers of lines, but it’s always paragraph text.

    And yes, the highlighting is going to work with text-animators at first. But I’m shure I can tweak your expression so it could also use a backdrop or anythig else! After all it does seem to return a position at some point.

    Again, thank you very much!

    Tilman

  • Filip Vandueren

    January 13, 2021 at 12:08 pm

    The only thing you have to look out with, if is the textanimators start changing position or scale of the highlighted characters.

  • Robert Müller

    January 14, 2021 at 2:24 pm

    Hi Filip, awesome expression set up you made there. Just out of curiosity, since I checked it out to learn a thing or two, I noticed that the expression sometimes does not work with certain fonts. I did not recognize a pattern, but the problem is always the same as that the coordinates pushed into the array are zero. As far as I understand the expression I did not find a reason for this, any idea why that is?

  • Filip Vandueren

    January 14, 2021 at 3:37 pm

    Maybe those fonts don’t have a pipe symbol, or a weirdly shaped one.

    Try disabling the expression selector of the “font height hack” animator, and then every character should be changed to a string like ||| | |||| | |

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