Forums › Adobe After Effects Expressions › Find out position of individual characters in text layer
Find out position of individual characters in text layer
Tilman Commes
January 9, 2021 at 4:18 pmHi!
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!Andrei Popa
January 12, 2021 at 8:19 amI 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 amPossible, 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 amTilman Commes
January 13, 2021 at 12:04 pmWow, 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 pmThe 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 pmHi 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 pmMaybe 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 ||| | |||| | |
Log in to reply.