Skip to main content
Participating Frequently
September 28, 2022
In Development

Ability to set text style attributes with expressions per index/character instead of per layer

  • September 28, 2022
  • 7 replies
  • 1421 views

Currently, I can read the style attributes per character using sourceTextProperty.getStyleAt(index). I should be able to set the styling in the same way, but instead you can only set it for the entire layer at once.  This would be a game-changer for MOGRTs and Essential Graphics as well, if I could copy the kerning from a live text layer and have it pass all that information to my EGP comp, it would be next level in terms of how much MOGRTs could accomplish.

 

For example, I have a stacked font that needs multiple layers to achieve the effect my client is looking for.  I also need to adjust leading/baseline shift etc, and doing this for each instance is repetitive and error-prone. If I could use a simple for-loop to copy this character by character this would significantly lessen the amount of work this takes.

 

Even better would be a set of additional methods that could set it all at once - something like .sourceText, but inclusive of all styling— .sourceTextAndStyle or something similar.

 

The following is how I could see this working:

 

var sourceTextProperty = thisComp.layer("SourceTextLayer").text.sourceTextAndStyle; //creates an exact copy of SourceTextLayer, which can then further be modified:
var newStyle = sourceTextProperty.getStyleAt(0,0);
newStyle.setStyleAt(0,5).setFont("Helvetica") .setBaselineShift(10);
//change the font from characters 0 - 5 to Helvetica with a baseline shift of +10

OR
var sourceTextProperty = thisComp.layer("SourceTextLayer").text.sourceText; 
var newStyle = sourceTextProperty.style;
for (i = 0; i < sourceTextProperty.length; i++){
   newStyle[i] = sourceTextProperty.style[i];
   //iterate through the style array and copy that style character-by-character.
}
newStyle.setFont("Helvetica");
//changes the font, but would keep all text attributes from sourceTextLayer intact.

 

I'm sure there are plenty of implementation details that I missed, but hopefully this gets the point across.

7 replies

JohnColombo17100380
Community Manager
Community Manager
June 18, 2024

Hi all,

We are happy to announce that this functionality is now available to try out in Public Beta. Full details can be found in the Beta forums: https://community.adobe.com/t5/after-effects-beta-discussions/now-in-beta-per-character-text-and-paragraph-styling-in-expressions/td-p/14624910 

 

Thanks again for your requests and input!

- John, After Effects Engineering Team 

Participating Frequently
April 16, 2024

Heya @DaciaSaenz, this script is similar to something I was working on... but unfortunately adding returns breaks it. This is also true in the file you shared. I've not been able to solve this issue. Any ideas how to deal with returns/line breaks?
Thanks.

SteveLewisZA822488
Participant
September 11, 2023

A different potential approach that I believe could be just as useful would be if you simply had a Font property amongst the properties that can be added to text animators, ie. you would be able to define a range in which that font gets applied to the text, or use expression selectors for more complex application of a different font across a single text layer.

dbDavideBoscolo
Legend
August 31, 2023

Yes, we need this! 

DaciaSaenz
Community Manager
Community Manager
June 21, 2023

This is for sure needed and on the list of feature requests for remaining text expressions to enable for users. 

In the meantime, there is this handy little workaround that was shared to me by a Mogrt Genius who was able to use Expression Selectors and some creative JavaScript to create a mark-up style way to do substring editing, i.e. make some letters bold, or subscript, or superscript. 
In the example shared in the attached file the end user simply puts special characters around the characters that they want to be bold within the text edit control. Por ejemplo, Dacia #loves# Mogrts would be rendered as Dacia loves Mogrts. 

 

Here's a link to a sample project with the expressions.

Hope this can help in the meantime,

Dacia

- Dacia Saenz, AE &amp; PR Engineering Teams
Kyle Hamrick
Community Expert
Community Expert
June 16, 2023

Oh man, the amount of workarounds this would eliminate would be very tasty indeed.

interactivePixels
Participating Frequently
September 28, 2022
It would be great to not only be able to use the "getStyleAt()" method, but also implement something like "setStyleAt()" in order to style portions of the text separately.

It would also help to be able to chain different styles together. Right now, it's impossible to do proper text styling with different style types programmatically. It would be incredibly helpful, especially for Templates / MOGRTs.
dbDavideBoscolo
Legend
September 28, 2022
Yes please