ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Re: Is there a way to keep a block of text always vertically centred?

COW Forums : Adobe After Effects Expressions

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Respond to this post   •   Return to posts index   •   Read entire thread


John Mitchell
Re: Is there a way to keep a block of text always vertically centred?
on Dec 2, 2016 at 4:17:36 am

Kevin - that's brilliant!

Your script is better than one that automatically centres the text on layer because that will automatically centre it around any vertical point. The offset needs to be half the value of the line spacing value - I don't know if you can reference that with an expression. I tried to search the web and it seems you can't - but I'm an expression novice.

So I did it with blunt force - first I set my line spacing to 0, then I added the line spacing animator control to the text layer.

I then adjusted the expression to:

temp = thisComp.layer("Text1").text.animator("Animator 1").property.lineSpacing[1]
offset = [temp]/2;
txt = text.sourceText.split('\r');
y = (txt.length-1)*offset;
value-[0,y]

Where it says "Text1" - that is the layer name of the text layer.

If you don't want to rename your text layers then you can always use a Control slider on a separate layer. I created one called LineSpacing and pickwhipped the line spacing animator control to it.

You then have to adjust that expression unless you want to indent as well as line space to:

temp = thisComp.layer("LineSpacing").effect("Slider Control")("Slider");
[0, temp]

Then the expression for the text value position property is:

temp = thisComp.layer("LineSpacing").effect("Slider Control")("Slider")
offset = [temp]/2;
txt = text.sourceText.split('\r');
y = (txt.length-1)*offset;
value-[0,y]

The only thing you lose with this is the AUTO setting in line attributes but I have found in the past that most fonts simply use the font size value for that.

temp = thisComp.layer("LineSpacing").effect("Slider Control")("Slider")
offset = [temp]/2;
txt = text.sourceText.split('\r');
y = (txt.length-1)*offset;
value-[0,y]




Posts IndexRead Thread 


Current Message Thread:





© 2020 CreativeCOW.net All Rights Reserved
[TOP]