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

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:

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
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
allCaps
read
boolean
true/false
applyFill
read/write
boolean
true/false
applyStroke
read/write
boolean
true/false
baselineShift
read/write
number
in range -1296-1296
boxText
read
boolean
true/false
boxTextPos
read/write
array of floats
[float,float] (if boxText is true)
boxTextSize
read/write
array of floats
[float,float] (if boxText is true)
fauxBold
read
boolean
true/false
fauxItalic
read
boolean
true/false
fillColor
read/write
array of floats
[r,g,b] (in range 0-1)
font
read/write
string
"Verdana" (Case Sensitive)
fontFamily
read
string
"Verdana"
fontLocation
read
string
"/Library/Fonts/Verdana.ttf"
fontSize
read/write
number
0.1-1296
fontStyle
read
string
"Regular"
horizontalScale
read/write
number
in range 0-100 (1 = 100% scale in ui)
justification
read/write
integer
left=7213, right=7214, center=7215 + if boxText == true :: last left=7216, last centered=7218, last right=7217, all=7219
pointText
read
boolean
true/false
smallCaps
read
boolean
true/false
strokeColor
read/write
array of floats
[0.1, 0.5, 1] [r,g,b] (in range 0-1)
strokeOverFill
read/write
boolean
true/false (only works for "Fill Over Stroke" and "Stroke Over Fill")
strokeWidth
read/write
number
in range 0-1000
subscript
read
boolean
true/false
superscript
read
boolean
true/false
text
read/write
string
"Anything"
tracking
read/write
integer
in range -1000-1000
tsume
read/write
number
in range 0-100
verticalScale
read/write
number
in range 0-100 (1 = 100% scale in ui)