Adjusting line space based on the text layer height
Posted: October 1st, 2019, 4:44 pm
Hey Guys! Feeling great to be here, I am currently working on a project, and trying to develop some expressions to help myself work smarter. And here are some details of what I am trying to achieve:
I have applied the following expression to the scale of a regular Point Text layer, then when the content you type in is wider then 500 pixels, it will scale down the layer so it won’t exceed 500 pixels

It’s working pretty nice.
But when I input line return to the text: since the expression scales the whole layer, including the vertical scale, the result is not visually what I want:

I hope to keep the line spacing between lines visually the same even after the scale expression scales down the whole layer:

So I developed the following expression, and put on the line space
This expression kind of works when I change the preview resolution to force the preview refresh, or use Edit>Purge>Image Cache Memory, but sometimes both ways won’t work

I assume the reason is because the line space expression makes it react to the layer height, but when the line spacing increases, the layer height will also increase, then the expression will make the line space to react to that again… which creates a “loop” and confuses the AE.
If that’s the case, I am wondering if that’s other way to achieve the line spacing purpose without creating that “loop”, or maybe a better/ easier way to force refresh the preview so it can work every time?
Any help will be greatly appreciated!
Attached with the AE file to better illustrate the situation:
https://www.dropbox.com/s/k8fbfsnxmgfuy ... e.aep?dl=0
I have applied the following expression to the scale of a regular Point Text layer, then when the content you type in is wider then 500 pixels, it will scale down the layer so it won’t exceed 500 pixels
Code: Select all
s=thisLayer;
scl=500;
x=s.sourceRectAtTime(time,false).width;
if (x>scl)
{[scl/x*value[0],scl/x*value[1]]}
else
{value}

It’s working pretty nice.
But when I input line return to the text: since the expression scales the whole layer, including the vertical scale, the result is not visually what I want:

I hope to keep the line spacing between lines visually the same even after the scale expression scales down the whole layer:

So I developed the following expression, and put on the line space
Code: Select all
TextHeight=sourceRectAtTime(time,false).height;
BeforeHeight=TextHeight;
AfterHeight=TextHeight*scale[1]/100;
LineSpace=(BeforeHeight-AfterHeight)/4*100/scale[1];
[value[0],LineSpace]
This expression kind of works when I change the preview resolution to force the preview refresh, or use Edit>Purge>Image Cache Memory, but sometimes both ways won’t work

I assume the reason is because the line space expression makes it react to the layer height, but when the line spacing increases, the layer height will also increase, then the expression will make the line space to react to that again… which creates a “loop” and confuses the AE.
If that’s the case, I am wondering if that’s other way to achieve the line spacing purpose without creating that “loop”, or maybe a better/ easier way to force refresh the preview so it can work every time?
Any help will be greatly appreciated!
Attached with the AE file to better illustrate the situation:
https://www.dropbox.com/s/k8fbfsnxmgfuy ... e.aep?dl=0