Using new text expression in AE2020 to apply multiple styles to a single text layer

New Here ,
Nov 05, 2019 Nov 05, 2019

Copy link to clipboard

Copied

Hi.

I'm playing around with After Effects 2020's new text expression tools
and I roughly understand about the newly added functions.

However I couldn't find the way to set multiple styles in a single layer.
What I wanted to do is : Only the first letter is set to bold and the rest will be left as it is.

 

SnapCrab_No-0506.png
(I know it's possible by setting manually without expressions)

Is there any way to do this?
What do you think?

TOPICS
Expressions , How to

Views

3.3K

Likes

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
Explorer ,
Nov 05, 2019 Nov 05, 2019

Copy link to clipboard

Copied

I have the same issue. I tried making 2 layers. The first had this expression to the text source :

 

value + thisComp.layer("layer2").text.sourceText.style.setFont("TimesNewRomanPS-BoldMT")

 

I expected to get the value plus the second layer content in bold TNR. Instead, i got the value plus "[object Object]" and no change to the style whatsoever.

 

 

Likes

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
Adobe Community Professional ,
Nov 05, 2019 Nov 05, 2019

Copy link to clipboard

Copied

The expression needs to start with style. They look like this:

 

var fs=effect("Slider Control")("Slider");
style.setBaselineShift(100);
style.setFont("TimesNewRomanPS-BoldMT");
style.setFontSize(fs)

 

I added an expression control slider and called it fs, then I set the baseline shift to 100, the font to Times New RomanPS-BoldMT, and set the font size to the value of the slider.

Screenshot_2019-11-05 23.16.55_33sHjE.png

 

The language is covered a bit in the new features page for AE. The expression language menu will also give you a clue to the right syntax. Anytime there is another panel that pops up with properties, one of the methods listed in the previous panels must precede it. 

Screenshot_2019-11-05 23.26.14_Pa0uls.png

Everything listed in the far left column must be preceded by either style. or getStyleAt(charindex, t=time). or createStyle(). I am sure that there will be more information coming soon.

Likes

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 ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

Thank you for your reply.

I've just added a picture to my original post which describes what I want to do.

Likes

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
Mentor ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

Not tested, but try simple string methods:

 

a = "T";

a.styleOfFirstLetter;

b = "e";

b.styleOfSecondLetter;

 

a+b;

 

*Martin

Likes

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
Enthusiast ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

That doesn't work. It looks like the + operator isn't defined for these objects (TextDocument I think it's called?), so the engine just casts the objects to strings resulting in  "[object Object][object Object]" being applied to the sourceText value.

 

Looking at the sparse documentation, I'm coming to the conclusion that you can only define a style for the entire text layer, which is pretty disappointing if true. I had really hoped this would finally give us the tools we need to automate type with mixed styles. This functionality will be useful, don't get me wrong, but if I'm right about this it's not the game changer I was hoping for.

 

I'd be really happy if someone can prove me wrong, though.

 

What's really peculiar is there is a function to *get* the style of an individual character, just not one to *set* it. I guess I can think of some marginal cases where the getter would be useful without the setter, but if for some reason I could only have one, I would definitely find the setter more useful.

Likes

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
Mentor ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

Word.

Likes

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 ,
Nov 07, 2019 Nov 07, 2019

Copy link to clipboard

Copied

Totally agree, we need *set* style !

Likes

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
Adobe Community Professional ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

Currently, you can "getStyleAt()" but "setStyleAt()" is not a function. If you reference another layer and you have manually set the first character to Faux Bold or even a different font you should be able to have that show up in a new text layer, but I don't see any method defined that would set a style at a specific character index. It would be a great feature request.

Likes

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
Enthusiast ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

If you reference the style of another text layer (without using getStyleAt()) all you get is the style of the first character, and it is applied to every character of the referencing layer. So your whole text layer will be faux bold, not just the first character.

Likes

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
Adobe Community Professional ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

You can use getStyleAt(3) to get the style of the fourth letter in a text layer. What is needed is setStyleAt(0) to set the style of the first letter in a new text layer. That option does not exist in the current release. I've already filed a feature request.

Likes

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
Enthusiast ,
Nov 07, 2019 Nov 07, 2019

Copy link to clipboard

Copied

If you'll link to the feature request I'll gladly vote for it.

Likes

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

Hi! Currently My AE2020 says sourceTextProperty.getStyleAt() is not a function =(

 

Likes

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 Beginner ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

LATEST

Hi, please check in the project settings that in the Expressions tab the Expression-Engine is set to JavaScript. All these text commands doesn't work with ExtendedScript.

Likes

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 Beginner ,
Dec 24, 2019 Dec 24, 2019

Copy link to clipboard

Copied

I too assumed this would be possible with the new text expressions and am sad to see it isn't. But a good start! Someday we'll be able to setStyleAt(). Hopefully.

Likes

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 Beginner ,
Feb 01, 2020 Feb 01, 2020

Copy link to clipboard

Copied

I also hope we will soon get setStyleAt() or for the text-animator engine the property to change beside leading, stroke, etc. also a different font. Because it will be so useful to animate important things in MORGT for subscriptions.

Likes

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 ,
Apr 06, 2020 Apr 06, 2020

Copy link to clipboard

Copied

I think I found a way to do with one text entry, however you’d need 2 additional text layers to render the text.

 

Crate layer 1 “srctxt” - enter you text here then hide the layer

 

Create layer 2 “reg” - Regular weight text Layer. in the source text expression, enter :

thisComp.layer("srctxt").text.sourceText.substr(1,thisComp.layer("srctxt").text.sourceText.length)

Then move the layer anchor point to the right edge of the layer.

 

Duplicate layer 2 and rename to “bold”, parent to layer 2 (reg), and make the text bold. Then replace the source text expression with:

thisComp.layer("srctxt").text.sourceText.substr(0,1)

 

Then twirl down to position in "bold" and enter this expression:

x = -1*thisComp.layer("text").sourceRectAtTime().width;

y = 0;

[x,y]

 

You may need to add a slider to control or some math to control the space between the "reg" and "bold" layers.

Likes

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 ,
Sep 05, 2020 Sep 05, 2020

Copy link to clipboard

Copied

For anyone that finds this in future,  Text Chain on aescripts worked well to combine various styles and dynamic / expression based text.

Likes

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 Beginner ,
Sep 07, 2020 Sep 07, 2020

Copy link to clipboard

Copied

Thank you for this hint! Unfortunatly it doesn't work for my purpose, because I have to develop a MOGRT that works in Premiere without Afer Effects installed on these computers. And normaly using third-party-plugins in the Essential Graphics panel needs an instance of After Effects and the plugin to work as a MOGRT in Premiere (which often slows the speed down in Premiere).

Likes

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 ,
Jan 20, 2022 Jan 20, 2022

Copy link to clipboard

Copied

Hello everyone!

I'm struggeling with this issue as well... any updates and solutions with new versions since we're in 2022 now?

Thanks

Likes

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
Adobe Community Professional ,
Jan 20, 2022 Jan 20, 2022

Copy link to clipboard

Copied

The limitation with Text Layer styles is you can only apply one style into a Text Layer. So, you'll require one Text Layer per style and then combine these into a word/sentence using Expressions to make it look like they're on a single text layer. 

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Likes

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