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

.setStyleAt()—ability to set text style attributes per index/character instead of per layer

Community Beginner ,
Jun 16, 2023 Jun 16, 2023

Copy link to clipboard

Copied

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.

Idea No status
TOPICS
Expressions

Views

343

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
5 Comments
Community Expert ,
Jun 16, 2023 Jun 16, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Adobe Employee ,
Jun 21, 2023 Jun 21, 2023

Copy link to clipboard

Copied

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 Engineering Team

Votes

Translate

Translate

Report

Report
Engaged ,
Aug 31, 2023 Aug 31, 2023

Copy link to clipboard

Copied

Yes, we need this! 

Votes

Translate

Translate

Report

Report
Explorer ,
Sep 11, 2023 Sep 11, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Explorer ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report