ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Adjust Text Position Animator with Expression that parses Source Text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Quest Rogers
Adjust Text Position Animator with Expression that parses Source Text
on Apr 24, 2018 at 6:57:02 pm

Hello!

I've been toying with a peculiar issue in After Effects with text layers. For some reason the spacing/kerning changes for many fonts between the first character and anchor point when numbers are typed. When numbers are typed they seem to shift an additional 3.5 pixels to the right of the anchor point. I don't know why this only happens when numbers are typed and it doesn't seem to be an restricted to any particular font because I tested several and the numbers always seem to shift to the right. In the attached screenshot both text fields have the same font, kerning (set to optical), and font size but you'll notice the numbers are shifted more to the right even though the only thing that changed was changing letters to numbers.


https://images.creativecow.net/312740/textshift.png

I'm looking for an expression that can check the source text layer for any numbers and change the X value of a position animator to compensate for this shift. If no numbers are detected in the source text the position doesn't change. The reason I'm looking for a solution to this is because when using sourceRectAtTime numbers often throw off the even spacing of the rectangle created behind the text.

I've been playing with the expression below but my lacking javascript knowledge is keeping me from figuring out a way to make this work. This works fine when I type all the numbers. But I can't quite figure out how to script the expression to not be conditional on all the numbers being present. I want it to work and change position if any numbers are present in the source text. Any ideas?

If anyone could help me figure this one out I'd greatly appreciate it!

Best,
Q

input = thisComp.layer(“TEXT”).text.sourceText;
if (input == “0123456789”) xPos = 0 else xPos = -3.5;
y = 0;
[xPos, y]


Return to posts index

Kalleheikki Kannisto
Re: Adjust Text Position Animator with Expression that parses Source Text
on Apr 29, 2018 at 1:12:09 pm

From what I can tell, the character that has the kerning problem is "1", the rest work just fine.

So you could do it this way:

input = text.sourceText;
if (input.charAt(0)==1){xPos = -3.5} else {xPos = 0};
value+[xPos, 0]


Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Quest Rogers
Re: Adjust Text Position Animator with Expression that parses Source Text
on Apr 30, 2018 at 3:39:44 pm

Kalleheikki,

Thanks for the reply! Yeah I discovered the kerning for "1" is what's causing the issue too. Your expression works great. Thanks for helping me figure this one out. Much appreciated!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]