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

Expression: Linking source text and font

New Here ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

Hello there! 

 

I'm am fairly new to expressions and quite awful at it so far. Below in the screenshot, there are two text layers that should be linked in terms of style & font but not the text itself. Thank you in advance for sifting through this mess!

 

Objectives:

1) The text itself for both layers should be pulled from their respective layer name, hence my attempt with "thisLayer.name

2) The font/style of the lower layer titled "I'm about halfway out the door." should be linked to that of the one right above, which I attempted with the line "style.setFont(thisComp.layer("Tell me now, I gotta know.").text.sourceText.style.font);"

 

Attempts/Observation: When I added the second expression (highlighted in yellow) for either layer, the first was no longer being interpreted, meaning the text was no longer reflecting the layer name in the preview. When I isolate just the line linking the second layer's font to the first, it works. There was no error underlied, but I still suspect there's a syntax error. 

 

text_troubleshooting_screenshot.png

 

TOPICS
Expressions

Views

225

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

correct answers 1 Correct answer

Community Expert , Mar 22, 2023 Mar 22, 2023

Try eliminating the thisLayer.name line and instead, append a .setText(thisLayer.name) to the second line. So, for example, the first expression would look like this:

style.setFont("Jattayu").setText(thisLayer.name);

 

Votes

Translate

Translate
Community Expert ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

Try eliminating the thisLayer.name line and instead, append a .setText(thisLayer.name) to the second line. So, for example, the first expression would look like this:

style.setFont("Jattayu").setText(thisLayer.name);

 

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
New Here ,
Mar 23, 2023 Mar 23, 2023

Copy link to clipboard

Copied

It worked!!! Thank you, Dan! I still wonder why the former was incorrect though. Could it be because multiple expression for the same property are not allowed? 

 

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
Community Expert ,
Mar 23, 2023 Mar 23, 2023

Copy link to clipboard

Copied

LATEST

That's basically it. The last result the expression calculates is the one that gets applied. So if you want to combine two or more expressions, you usually need to gather their results temporarily into variables and then somehow combine them in the last statement executed.

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