ExtendScript changes text area line count; now will not center text
Thanks in advance for your help with this:
I have a comp with a Text Area with 5 lines of English placeholder text in the project. The text layer is centered over a shape layer.
When my ExtendScript replaces the 5 English lines with its Russian translation, which is 6 lines, the Text Area grows horizontally … at the bottom; now the text is no longer horizontally centered over the shape.
To fix this centering issue, I have the following script for the “Anchor Point”:
s=sourceRectAtTime();[0,s.top+s.height/2]+value;
Works beautifully as you can see. BUT: the paragraph alignment, which was set to “Center Text” somehow gets changed to “Left Align Text” (red rectangle)!
Even if I force alignment after changing the text with :
textDocument.justification = ParagraphJustification.CENTER_JUSTIFY;
Makes no difference, the text remains left justified.
Abbreviated code:
for (var gg = 1; gg <= numLayers; gg++) {
if (app.project.item(y).layer(gg).property("Source Text") !== null) {
replaceText = (4 lines of text from a JSON file)
app.project.item(y).layer(gg).property("Source Text").setValue(replaceText); // replaceText with the 4 lines
textProp = app.project.item(y).layer(gg).property("Source Text");
textDocument = textProp.value;
textDocument.justification = ParagraphJustification.CENTER_JUSTIFY; // Force Center Justify
}
}

