Skip to main content
Participant
November 27, 2023
Question

Trying to Scale font size down as words are added

  • November 27, 2023
  • 1 reply
  • 225 views

I have a text layer in a text box. With fewer words I want the text to be at a maximum font size and as more words (and lines) are added I want the font size to scale down to a minumum size.

I have a null controller with a slider control (output) with this code

 

var driver = thisComp.layer("Display Text").sourceRectAtTime().height;

var dMin = 845;

var dMax = 1300;

var pMin = 305;

var pMax = 240;

linear(driver, dMin, dMax, pMin, pMax)

 

On the source text of text layer I have this code.

 

var FS = thisComp.layer("Controller").effect("Output")("Slider"); text.sourceText.style.setFontSize(FS).setLeading(FS)

 

When I add words and lines I can see in the properties panel that the font size is going down, but it still displays at the original (max) font size.

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
November 27, 2023

Weird things can happen when you create an expression loop where 2 or more expressions depend on each other's results. In this case, you're setting font size based on sourceRectAtTime(). But sourceRectAtTime() is affected by font size, so the result can be unpredictable. As I recall, in the early days of expressions, the expression engine was more adamant about not letting you set up dependent loops like that.

Participant
November 27, 2023

Thanks Dan.

 

The curse of the recusive.