• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Trying to Scale font size down as words are added

Community Beginner ,
Nov 27, 2023 Nov 27, 2023

Copy link to clipboard

Copied

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.

TOPICS
Expressions

Views

95

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2023 Nov 27, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 27, 2023 Nov 27, 2023

Copy link to clipboard

Copied

LATEST

Thanks Dan.

 

The curse of the recusive.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines