I am trying to apply stroke to my photoshop text using scripts. But I have failed all the time. Here’s what I’ve come up with:
#target photoshop
var textArray = ["Hello"];
var fontSize = 13;
var fontFamily = "KomikaAxis";
var strokeSize = 10;
for (var i = 0; i < textArray.length; i++) {
var currentText = textArray[i];
var textLayer = app.activeDocument.artLayers.add();
textLayer.kind = LayerKind.TEXT;
textLayer.textItem.contents = currentText;
textLayer.textItem.font = fontFamily;
textLayer.textItem.size = fontSize;
var textColor = new SolidColor();
textColor.rgb.red = 255;
textColor.rgb.green = 255;
textColor.rgb.blue = 255;
textLayer.textItem.color = textColor;
textLayer.textItem.position = [541, 1144];
textLayer.rasterize(RasterizeType.TEXTCONTENTS);
textLayer.layerStyle.stroke.enabled = true;
textLayer.layerStyle.stroke.size = strokeSize;
textLayer.layerStyle.stroke.color = new SolidColor();
textLayer.layerStyle.stroke.color.rgb.hexValue = '000000';
textLayer.layerStyle.stroke.position = StrokeLocation.CENTER;
textLayer.layerStyle.stroke.blendMode = BlendMode.NORMAL;
}
I have run the code and it says undefined is not an object at line:
textLayer.layerStyle.stroke.enabled = true;
Why is so? The text is made surely, not the stroke.
What am I making wrong here?