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

AE expression to link source text and font size

New Here ,
Aug 31, 2023 Aug 31, 2023

Copy link to clipboard

Copied

I am very new at writing/combining AE expressions and often spend a lot of time on these forums to find solutions. Usually I find everything I need relatively quickly, but this for this new MOGRT I am creating I am having difficulties getting everything to work properly.

 

Basically, I have two text layers and I want the main text layer to be the parent that the secondary text layer references for the source text values (such as any characters/numbers types) and for font size. The first part is easily done, the issue comes when I try to link the secondary text layer's font size to the main text layer's. When trying to apply the font size to the layer it replaces the source text value, but does not replicate the text's paragraph breaks and so the text just runs off screen. I've spent hours trying to figure this out and have used many other forum threads to get to this point so any and all help is appeciated.

 

Current Expression:

 

txt = thisComp.layer("MainText")

sourceText = thisComp.layer("MainText").text.sourceText;

fontSize = thisComp.layer("Extra Controls").effect("Font Size")("Slider");

createStyle().setFontSize(fontSize).setText(txt)

 

The attached image shows the text runoff in the green highlighted area. The word "priorites" should have dropped to the second line following the main text.

Screenshot 2023-08-31 at 8.22.32 AM.png

TOPICS
Expressions

Views

460

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 ,
Aug 31, 2023 Aug 31, 2023

Copy link to clipboard

Copied

LATEST

There are two types of text layers. Paragraph Text and Point Text. You can define the size of the Paragraph Text Box by clicking and dragging with the text tool. Unfortunately, you cannot define the size of a Paragraph Text Box with an expression. You can convert Paragraph Text to Point text using a contextual menu available with a right-click in the Comp panel when a text layer is selected, and the type tool is active, but you have not clicked on the text to edit it yet. Unfortunately, there is no way to control or copy the size of a Paragraph Text Box with an expression or a script. You will have to duplicate the Paragraph text layer. 

 

You also cannot define a character range to change the character attributes (size, kerning, font) with an expression. You can only select a character index to make the change. 

 

Creating the project you describe will require a bunch of expressions, sliders, at least two text layers, and a matte layer created from a shape layer with Trim Paths added. The project would look something like this before you start working in the Essential Graphics workspace to build your Mogrt.

RickGerard_0-1693513360833.gif

I used the Middle text layer as a control, and this is the expression for the text property:

ref = thisLayer;
trk = ref.text.sourceText.style.tracking;
sTrack = ref.effect("Tracking")("Slider") + trk; 
strtSize = ref.text.sourceText.style.fontSize;
fSize = ref.effect("Font Size")("Slider") + strtSize;
blShift = ref.effect("Baseline Shift")("Slider");
styl = text.sourceText.style.setFontSize(fSize).setTracking(sTrack).setBaselineShift(blShift);

Depending on your requirements, you may need to add more controls. There is a limit to what you can do with the sourceText.style properties.

 

There are too many other expressions to post here, so I have uploaded a couple of project files that may get you started. The Guides were added to the comp so I could snap the Paragraph Text box to the same size while I was editing the comp.

 

I don't know if this will help, but it's the only thing I could think of allowing you to edit text and modify the font and matte for a specific word.

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