Copy link to clipboard
Copied
Hi everyone!
We're excited to announce that starting in version 24.5.0x41 of After Effects Beta introduces support for per-character control of text and paragraph styling in Expressions.
This long-requested addition to Expressions builds on recent per-character scripting API updates to unlock powerful text styling capabilities that are able to respond to changes in text content and can be saved and shared as presets. These new options can also streamline template design by making it possible to configure alignment and paragraph styling in a single layer rather than turning on and off multiple synced copies of a layer.
A benefit of per-character control is automatic reflowing of text such as when scaling letters, using superscript, and using a different font, just as you would expect from using substring styling from the Character panel.
Getting Started
Make sure you have your expression engine set to Javascript.
The Expression reference flyout menu provides an overview of available methods in the updated Text > Styling submenu; see the attached document for the full API.
Sample Expressions
Change the font for certain words
Using the string: “Change the fonts of some words” apply the following to the Source Text
text.sourceText.style
.setFont("Montserrat-Light")
.setFont("Gigantic", 0, 6).setFont("Gigantic", 10, 6).setFont("Gigantic", 20)
To customize this for yourself, change the font from the Text Expression flyout menu, and target the character index and amount of characters to make a different font.
Set the first line of a text layer to bold and make it larger
Using the string: “Change the first line of text to bold and make it larger” apply the following to the Source Text
text.sourceText.style.setFontSize(100, 0, 30).setFauxBold(true, 0, 30)
Set superscript for characters
Using the string: “1st and 2nd Place” apply the following to the Source Text
text.sourceText.style.setBaselineOption("superscript",1,2).setBaselineOption("superscript", 9, 2)
Try passing character index values and character amounts to expression sliders and using keyframes to create animation!
Known Issues
Limitations
The style object always returns the first character's style information, not the characters' individual substyles. Therefore, when reading the style of a Text layer containing multiple styles, you must use getStyleAt() with a character index to specify which character's style you need.
We've built an example AEP with the above expressions and few extras to get you started. Please give all of these new expressions a try and let us know how they’re working for you!
Copy link to clipboard
Copied
Cool! Thanks for sharing. Always good to see the work of others.
Copy link to clipboard
Copied
On Number of Lines for Paragraph Text, I've always wondered why internally this number is available via the Range Selector when you switch Units from Percentage @ 100% to Character Index but it's been like locked away from Expressions.
It'll be great if this (numberOfLines thingy) is accessible via a function/method and directly used within the Start/End Range Selectors in a straightforward manner.
Copy link to clipboard
Copied
This looks amazing, we've been waiting to be able to do this for ages..
Is there any news on when it will be available in the release version of AE?
Copy link to clipboard
Copied
Yes! Hyped for this. I've updated Motion Developers `style-parser` to use these new beta features, check out the PR/example project file. Shoutout to @Volition74au for commenting the `eval()` code snippets in this thread!
Copy link to clipboard
Copied
Have feedback for setJustification()
Using this expression copies all Style settings from "Text 1", including paragraph justification.
thisComp.layer("Text 1").text.sourceText.style
However, the expression below copies Style settings, sets Text, and then throws away the paragraph justification set via Style.
thisComp.layer("Text 1").text.sourceText.style.setText(thisComp.layer("Text 1").text.sourceText)
This is inconsistent behavior compared to all the other style attributes. Doesn't make sense for Justification to be ignored, unless it is explicitly overrode later in the chain.
It is also inconvenient.
I kept the expressions barebones so this is clear.
Request:
Please match the established behavior for all Style attributes. ".style" should copy all style attributes unless overridden later in the chain.
Copy link to clipboard
Copied
A mix of setHorizontalScaling, setBaselineShift, setFillColor
Copy link to clipboard
Copied
The sample below was done entirely with Text Animators.
I see the new styling features more for non-animation use-cases. There is definitely opportunity to explore creative options in the area for sure.
Congrats to the team on getting this out - such a huge task.
Copy link to clipboard
Copied
@therethere Would it be possible to add a javascript method to access the transform properties of the character bounding boxes that appear when Per-character 3D is enabled?
This way we'll be able to create very dynamic/reactive text effects like this:
Currently, it can be done in After Effects by converting the text into shape layer, but it's tedious, the text is no longer editable, and you have to apply expressions to all the shapes, which causes it to lag very quickly.
Copy link to clipboard
Copied
This Reactive Effect uses Text Animators.
Copy link to clipboard
Copied
@Roland Kahlenberg Yes, but it's still very limited and linear.
Look at the example above, the letters move in all directions based on the angle and the distance they have from the mouse cursor, and for that, you absolutely need to know the position of each letter.
And it makes things simpler the animation above is 60 lines of code.
Copy link to clipboard
Copied
You did ask about proximity. 🙂
So, yes you can do it with AE's Text Animators. The example you provided requires Affected Characters knowing the relative position of the Effector. And if the Effector is [above, below,noDifference] the Affected Characters will move differently. I've tried this but it's been a while - I'm quite certain I managed to pull it off or at least the Text Animators did do the job.
On the example you shared, in AE, I would break up the paragraph into individual lines - quite easy to do with Javascript String Manipulation - single paragraph input and then have each Text Layer/Line grab its text string/line. All the Proximity Code will be identical so this helps simplify the set up too.
And it's dangerous to compare with JS Text Tools on the web cos they can do amazing stuff and very quickly too. And of course, per character Rect Boundary, be default is always good to have. And there are Particle Generators in AE that may provide an efficient solution to the sample you shared.
A while back, I shared the AEP to the sample I shared. If you want to take a look, I can dig it up and post it on my site.
Copy link to clipboard
Copied
Hello! Nice to see what expression on text could do now, thanks for that update!
I'm wondering, is it possible to set with expression text direction ? (Right to Left, Left to right) for examle - for arabic language...
If not, could you add this feature ?)
Copy link to clipboard
Copied
@Oleh BetterMe Yes, you can set expression text direction (LTR/RTL) with:
style.setDirection("left-to-right"); style.setDirection("right-to-left");
Copy link to clipboard
Copied
Amazing, thanks!
Copy link to clipboard
Copied
Thank you! your attached ae proj. is of a great help.