Skip to main content
Participant
March 7, 2019
Question

Expression for text width/scale depending on another text width/scale

  • March 7, 2019
  • 2 replies
  • 4842 views

Hey guys,

i am pretty new to expressions (Just know some basics) and i ran into a problem.

I am creating a template right now and the user should be able to enter two titles: One main title and a subtitle.

I want the subtitle to have the same width as the main title.

Is there any way to get this done automatically?

So for example the user writes into the first title: The Doggo Loves Walkies, and into the second title: The True Story Of The Doggo.

The second title should then scale up or down, depending on the width of the first title so that they line up on both sides.

Sorry for the bad explanation...I hope you understand what I mean...

Let me know if my idea is stupid and there is a much easier way to get this done.

Thank you already!

This topic has been closed for replies.

2 replies

DatingTian33834613
Participant
March 8, 2019

你可以试试这个表达式transform.ypositon+index*数值

Dan Ebberts
Community Expert
Community Expert
March 7, 2019

You could try a scale expression like this:

w1 = thisComp.layer("First Title").sourceRectAtTime(time,false).width;

w2 = sourceRectAtTime(time,false).width;

s = (w1/w2)*100;

[s,value[1]]

Dan

Weezle_33Author
Participant
March 8, 2019

Hey Dan,

that works perfect! Exactly what I was looking for! Thank you man.