Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Need Text expression help with specific style properties.

  • Need Text expression help with specific style properties.

    Posted by Kevin Thompson on August 14, 2024 at 6:43 pm

    Hi, I’m trying to find some help for styling multiple type layers.
    Here’s my goal:
    Text Layer 1: is the master text layer. I can use this to change the text, font, font size, tracking, leading if needed.

    Text Layer 2 & others: I want these to copy the exact text, font, font size, tracking, leading of the master Text Layer 1, but I want to be able to apply different fill color, stroke on or off, stroke width, stroke color that’s independent of Text Layer 1.

    I’ve looked into expressions that copy style but was unable to customize it so that I can exclude certain style properties or set properties independent of the whole style. Greatly appreciate any guidance here!

    Dan Ebberts replied 1 year, 11 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    August 14, 2024 at 7:05 pm

    I think this will just pick up the style attributes you mentioned from Text Layer 1 and leave the rest untouched:

    txt = thisComp.layer("Text Layer 1").text.sourceText;
    s = txt.style;
    thisProperty.style.setFont(s.font).setFontSize(s.fontSize).setText(txt).setLeading(s.leading).setTracking(s.tracking);
  • Kevin Thompson

    August 15, 2024 at 2:20 pm

    NICE! Thanks! Also, new to these forums, how do I post script properly?

    I had figured out a work around piecing together Adobe’s examples on their website which involved excluding various properties from the copied style but yours is much more concise, haha.

    var newStyle = thisComp.layer(“Layer 1”).text.sourceText.style;

    var matchText = thisComp.layer(“Layer 1”).text.sourceText;

    var currentFillColor = thisProperty.style.fillColor;

    var currentStrokeOn = thisProperty.style.applyStroke;

    var currentStrokeWidth = thisProperty.style.strokeWidth;

    var currentStrokeColor = thisProperty.style.strokeColor;


    newStyle.setText(matchText)

    .setFillColor(currentFillColor)

    .setApplyStroke(currentStrokeOn)

    .setStrokeWidth(currentStrokeWidth)

    .setStrokeColor(currentStrokeColor);

  • Dan Ebberts

    August 15, 2024 at 3:04 pm

    >Also, new to these forums, how do I post script properly?

    Paste your code into your response, then click the Aa button below your post, then select your code and click the </> button.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy