Skip to main content
Known Participant
July 2, 2024
Question

Character Style Expressions not working

  • July 2, 2024
  • 2 replies
  • 374 views

I can't change any text properties of a text using the STYLE commands.
I must be using it totally wrong.
Why doesn't this work?

 

thisLayer.text.sourceText.setFontSize(50);

Whatever the syntax of the STYLE commands is, I find it completely incomprehensible.
None of the documentation on the internet works for me.
Even chatgpt gave up.
Is there anyone who can show in babysteps how to set omething correctly?
(please mark variables with a _ somewhere or else I get confused to see variables among the commandos)

This topic has been closed for replies.

2 replies

Roland Kahlenberg
Legend
July 3, 2024

As Dan has suggested, you need to start your text styling with a "style" syntax. There are only TWO ways you will really use te style syntax - (1) Reference another Text Layer's Style (2) Reference the Current Text Layer's Style.

You use "style" when referencing the Current Text Layer. When referencing Another Text Layer's Style, you MUST reference that layer and its style - like this -

textStyleFromAnotherLayer = thisComp.layer("HeaderText").text.sourceText.style;

IMPORTANT to take note you have to reference the other layer's text.sourceText.style attribute, in full.

When referencing the Current Text Layer's Style, you do not have to reference text.sourceText UNLESS you want to reference it by changing its text string and this is usually done before declaring the style statement/code.

So, in your case, all that is required is - 

style.setFontSize(50) 

HTH


Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Known Participant
July 2, 2024

motiondeveloper .com says this:

This is partly because they break one of the unwritten "rules" of expressions, which is that expressions can only set the value for the property they're on.

I do not even understand that. I feel I'm so close but where are the cigars?

Dan Ebberts
Community Expert
Community Expert
July 2, 2024

Try this:

style.setFontSize(50)

then this:

style.setFontSize(50).setText("new text")

That should help you get the hang of how it works.