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

Expression to change font size on a new line of text

Community Beginner ,
Jul 24, 2022 Jul 24, 2022

Hey there,

 

I'm a total hack when it comes to expressions so my apologies for asking what is probably a very basic question with a simple answer.

 

I'm trying to create a text layer with 2 lines of text. The first line is linked to a slider so I can animate it and beneath it (on a second line) I just want the word "Growth". I've managed to get that happening fine with this expression: Math.round(effect("Slider Control")("Slider"))+"x"+"\r" + "GROWTH"

 

However I want to be able to control the font size of just the word "Growth",  rather than changing the font size of all the text. I can't work out how to use a 'setfontsize' modifier on just that one word/line.

 

Any help would be much appreciated.

 

Cheers

Tim

TOPICS
Expressions , Scripting
2.2K
Translate
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 ,
Jul 24, 2022 Jul 24, 2022

I am pretty sure that the setFontSize operator only operates on the entire line of text. Here's the documentation.

 

https://helpx.adobe.com/after-effects/using/expressions-text-properties.html

Translate
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 ,
Jul 24, 2022 Jul 24, 2022

Thanks for your prompt reply Rick. If not the setFontSize operator, would you know of another way to achieve what I described? Or should I resort to just creating another separate text layer?

Translate
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 ,
Jul 25, 2022 Jul 25, 2022

I have created about twenty Animation Presets for controlling text layers, backgrounds for text layers, and graphics associated with text layers. The heart of all of them is sourceRectAtTime.

 

You can retrieve any text layer's height, width, and position by using height, top, width, and left values. This expression puts the bottom layer underneath the top layer and lines up the left side no matter the paragraph justification for either layer.

// look at the layer above
ref = thisComp.layer(index -1)
p = ref.position;
s = ref.sourceRectAtTime();
tl = sourceRectAtTime().left;
sf = scale[1] * .01;
pad = 10;// 10 pixel padding
p +  [s.left - tl, pad + s.height * sf]

 Add that expression to the position property of the text layer below the main text, and it will always be below the left layer and lined up with the left edge. You can then adjust the bottom text layer's scale to control that layer's size. You could also add a slider to control scale if you like and another slider for padding.

 

Select the bottom text layer's position property and save it as a custom animation preset, and you have a tool you can use any time. It also would work with Essential Graphics to create a MOGRT for Premiere Pro.

 

 

 

 

Translate
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
LEGEND ,
Jul 25, 2022 Jul 25, 2022

You can always add a size/ scale text animator and set its mode to per line. Depending on what fonts you use the results may vary, though, and could be unsatisfying, since the kerning and some otehr stuff affecting visual rendering won't be adjusted and will look differently at different sizes.

 

Mylenium

Translate
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 ,
Jul 25, 2022 Jul 25, 2022

Another option is to use multiple text layers. To attach the second text to the bottom of the first one, you can either write position expressions with sourceRectAtTime, or use my tool Pins & Boxes.

https://aescripts.com/pins-and-boxes/

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
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 ,
Jul 25, 2022 Jul 25, 2022
LATEST

Thanks everyone for the answers!! I will give them all a go and I'm sure one will do the trick!! Much appreciated.

 

Translate
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