Change Font and Font Style by script

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
adayres
Posts: 1
Joined: March 26th, 2014, 3:29 am

March 20th, 2017, 5:25 am

Hello,

For a client, I have to change the Font of  text layer with a script.
I manage to change the Font itself like this:

Code: Select all

var textProp = 	app.project.activeItem.layer(1).property("Source Text");
		var textDocument = textProp.value;
		textDocument.font = "Arial";
textProp.setValue(textDocument);

But unfortunately I don't manage to change the style
With the line below, After Effects return fontSyle is in ReadOnly  :(  

Code: Select all

textDocument.fontStyle = "Bold";
Does a magic trick exist?
Or maybe simply another way to do this?
Thanks by advance,
Aurélien
User avatar
zlovatt
Posts: 24
Joined: October 31st, 2016, 5:00 pm
Location: Los Angeles
Contact:

March 20th, 2017, 1:57 pm

Via Tomas Sinkunas, these are all the script-accessible text properties.

It looks like you'll need to set the font to "Arial-Bold" and that could work.

Code: Select all

var textLayer = comp1_comp.layers.addText("This is BOLD");
var textLayer_TextProp = textLayer.property("ADBE Text Properties").property("ADBE Text Document");
var textLayer_TextDocument = textLayer_TextProp.value;
textLayer_TextDocument.font = "Arial-BoldMT";
textLayer_TextDocument.fontSize = 36;
textLayer_TextDocument.applyFill = true;
textLayer_TextDocument.fillColor = [0.29019600152969, 0.6941180229187, 0.835294008255];
textLayer_TextDocument.applyStroke = false;
textLayer_TextDocument.justification = ParagraphJustification.CENTER_JUSTIFY;
textLayer_TextDocument.tracking = 30;
if (parseFloat(app.version) >= 13.2) {
	textLayer_TextDocument.verticalScale = 1;
	textLayer_TextDocument.horizontalScale = 1;
	textLayer_TextDocument.baselineShift = 0;
	textLayer_TextDocument.tsume = 0;
	// These values are read-only. You have to set them manually in the comp.
	// textLayer_TextDocument.fauxBold = false;
	// textLayer_TextDocument.fauxItalic = false;
	// textLayer_TextDocument.allCaps = false;
	// textLayer_TextDocument.smallCaps = false;
	// textLayer_TextDocument.superscript = false;
	// textLayer_TextDocument.subscript = false;
}
textLayer_TextProp.setValue(textLayer_TextDocument);
Post Reply