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

Is this Font Size Expression possible?

New Here ,
Mar 21, 2024 Mar 21, 2024

Copy link to clipboard

Copied

I want to set up an expression where I can control the font size, but I want to limit how small/big that font size can go to using the slider. Is this possible?

 

For example.... If I want to limit the user to a range between 20 and 50 using the slider.

 

Appreciate any insight that could be provided!

TOPICS
Expressions

Views

156

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

correct answers 1 Correct answer

Community Expert , Mar 21, 2024 Mar 21, 2024

In that case, it would be like this:

sl = thisComp.layer("Slider").effect("Slider Control")("Slider");
style.setFontSize(clamp(sl,20,50))

Votes

Translate

Translate
LEGEND ,
Mar 21, 2024 Mar 21, 2024

Copy link to clipboard

Copied

A simple linear(slider value, min, max) will do or alternatively a JS math clamp().

 

Mylenium 

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
New Here ,
Mar 21, 2024 Mar 21, 2024

Copy link to clipboard

Copied

So something like this would work?

 

clamp(value, min=20, max=20)

 

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
New Here ,
Mar 21, 2024 Mar 21, 2024

Copy link to clipboard

Copied

I'm also reading that connecting the font size to a slider expression isn't possible.... just the font scale is possible.

 

My attempts so far have given errors. If it is possible, how should the coding look?

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 Expert ,
Mar 21, 2024 Mar 21, 2024

Copy link to clipboard

Copied

Something like this for source text should do it:

sl = effect("Slider Control")("Slider");
style.setFontSize(clamp(sl,20,50))

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
New Here ,
Mar 21, 2024 Mar 21, 2024

Copy link to clipboard

Copied

Sorry.... still new to the coding aspect of expressions...

 

If I pickwhip the source text to the slide expression on a Null layer, I get this as a result - 

thisComp.layer("Slider").effect("Slider Control")("Slider")

 

I'm assuming that I have to do something like this to connect it all together - 

 

thisComp.layer("Slider");
sl = effect("Slider Control")("Slider");
style.setFontSize(clamp(sl,20,50))

 

Unfortunately, I'm getting an error and I'm unsure what is throwing it. Thank you again for this help. I want to learn this better and understand it better.

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 Expert ,
Mar 21, 2024 Mar 21, 2024

Copy link to clipboard

Copied

In that case, it would be like this:

sl = thisComp.layer("Slider").effect("Slider Control")("Slider");
style.setFontSize(clamp(sl,20,50))

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
New Here ,
Mar 21, 2024 Mar 21, 2024

Copy link to clipboard

Copied

LATEST

Now it's working. I thought I tried a version like that, but I kept getting an error. Thank you very much!

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