🔡

Sync AE Font Attributes

type
article
tags
after effects
tl;dr
Sync (some) text layer props with JavaScript
date
Oct 18, 2017

Edit 2

Jul 10, 2021
It’s been a while but I’ve just stumbled upon this little video that actually explains a very simple way to just expression link layers together to copy their style. Haven’t tried it so I’m not sure how many styles are actually supported but thought I’d link it here because it’s relevant to the topic: https://youtu.be/5hTVqDleABU

Edit 1

Sooo, this turned into a larger R&D session about text layers than I had expected. It seems that the JavaScript API's access to text layer's properties has some limitations as well. I spent some time reading the docs once more and testing every property and made a simple overview of what won't sync so You won't get unpleasantly surprised:
Attributes that can't be modified via JavaScript and therefore can't be synced between text layers
Attributes that can't be modified via JavaScript and therefore can't be synced between text layers
It makes sense that some settings - like kerning, which is a per-character setting - can't be modified as simply as say the font. Others like the Stroke/Fill rules seem more like a bug in the API than a sensible restriction (I hope that some guy from Adobe will see my post on the After Effects Scripting forum and give some feedback/insight). For now I can't do much more about the limitations mentioned. Of course the script might still be helpful in some cases despite the limitations.
All test results were acquired through After Effects CC2015 (13.5.0.347), information from the After-Effects-CS6-Scripting-Guide.pdf and a bunch of web searches.
In case anyone wants to try and fiddle with it themselves, here's how to modify a text layer's properties via JavaScript:
// Get text layer's Source Text property
var prp = app.project.activeItem.layer(1).property("Source Text")
// Assign to text layer to be able to edit properties
prp.setValue(new TextDocument(prp.value.text))
var doc = prp.value
// Make some changes to the TextDocument
doc.text = "Something"
doc.font = "Verdana"
if(doc.applyFill){
doc.fillColor = [0.1,0.5,1]
}
// Assign the modified TextDocument to the text layer
prp.setValue(doc)
And here's an overview of the properties available to the JavaScript API on a text layer's Source Text property and which values to get/set:
Property
Access
Value type
Value example/Description
read
boolean
true/false
read/write
boolean
true/false
read/write
boolean
true/false
read/write
number
in range -1296-1296
read
boolean
true/false
read/write
array of floats
[float,float] (if boxText is true)
read/write
array of floats
[float,float] (if boxText is true)
read
boolean
true/false
read
boolean
true/false
read/write
array of floats
[r,g,b] (in range 0-1)
read/write
string
"Verdana" (Case Sensitive)
read
string
"Verdana"
read
string
"/Library/Fonts/Verdana.ttf"
read/write
number
0.1-1296
read
string
"Regular"
read/write
number
in range 0-100 (1 = 100% scale in ui)
read/write
integer
left=7213, right=7214, center=7215 + if boxText == true :: last left=7216, last centered=7218, last right=7217, all=7219
read
boolean
true/false
read
boolean
true/false
read/write
array of floats
[0.1, 0.5, 1] [r,g,b] (in range 0-1)
read/write
boolean
true/false (only works for "Fill Over Stroke" and "Stroke Over Fill")
read/write
number
in range 0-1000
read
boolean
true/false
read
boolean
true/false
read/write
string
"Anything"
read/write
integer
in range -1000-1000
read/write
number
in range 0-100
read/write
number
in range 0-100 (1 = 100% scale in ui)

Initial Post

A graphics artist colleague of mine, had a request about syncing After Effects text layers' attributes (font, font size etc.) via expressions. Unfortunately at the time of writing this You can only link the contents of the text, but not its attributes. So I made the next best thing: A small script that does it at the push of a button:
notion image