Skip to main content
Participating Frequently
July 9, 2025
Answered

Control both source text and text style through separate expressions

  • July 9, 2025
  • 1 reply
  • 197 views

I need to create a template composition with a text box that has both its text content and text styling controlled through two different expressions. Ultimately, I need to make multiple versions of the same comp where both text source and style can be changed with the essential graphics panel. The issue that I'm running into is that the new text expressions seem like they can control either styling or content, but not both - whatever bit of code I write into the expression undoes what I had done previously. For example, if I were to write...

text.sourceText.content = "Adjusted Text"

text.sourceText.style
	.setFontSize(thisComp.layer("effectsSliders").effect("FontSize")("Slider"))
	.setFont("arial")

 ...then I would get the styling that I want, but I wouldn't be able to change the content. If I were to re-arrange the code to look like this... 

text.sourceText.style
	.setFontSize(thisComp.layer("effectsSliders").effect("FontSize")("Slider"))
	.setFont("arial")
	
text.sourceText.content = "Adjusted Text"

...then I would be able to control the source text, but not the styling.

 

I've looked through the resources that Adobe has posted, but I don't see anything that would allow me to do what I need to do. Does anyone know how to control both the content and the style of a text layer with two different expressions?

 

Any help would be appreciated

Correct answer Dan Ebberts

Try it this way:

txt = "Adjusted Text";
text.sourceText.style
    .setFontSize(thisComp.layer("effectsSliders").effect("FontSize")("Slider"))
    .setFont("Arial")
    .setText(txt)

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
July 9, 2025

Try it this way:

txt = "Adjusted Text";
text.sourceText.style
    .setFontSize(thisComp.layer("effectsSliders").effect("FontSize")("Slider"))
    .setFont("Arial")
    .setText(txt)
Participating Frequently
July 10, 2025

That did it! Thank you for your quick and simple reply, and thank you for saving my career for the past decade 🙂