Skip to main content
Participant
July 23, 2012
Question

AfterEffects Localization

  • July 23, 2012
  • 1 reply
  • 1349 views

I am writing a localization script that will load in an XML with language strings to replace text in my AE composition. I need to be able to switch out font families. Is there a way to change font families through a script?

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
July 23, 2012

You can change the font of a text layer like this:

var myFontName = "MyriadPro-Regular";

var myComp = app.project.activeItem;

var myTextLayer = myComp.layer(1);

var mySourceText = myTextLayer.property("Text").property("Source Text");

var myTextDoc = mySourceText.value;

myTextDoc.font = myFontName;

mySourceText.setValue(myTextDoc);

I'm not sure about font families.

Dan

Inspiring
July 27, 2012

You will probably need a conversion table to first read the current font settings from the text layer then use straight up conversions or regular expressions to extract the relevant parts ("Condensed, Light, Medium, Regular, Bold, etc.) to determine the size, style and weight of the new font.  Then set the value as Dan described.