Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: Is there a way to quickly break a single text box into multiple text boxes?

$
0
0

I don’t think what you want is convenient to achieve in various possible situations.

Hndling different fonts, sizes and other settings would be highly cumbersome.

If all the text has the same type parameters you can give this a try.

// split lines from active typelayer;

// makes sense if the type properties are uniform;

// 2014, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

var theLayer = myDocument.activeLayer;

if (theLayer.kind == LayerKind.TEXT) {

// get text an dleading;

var theText = theLayer.textItem.contents.split("\r");

try {

var theLeading = theLayer.textItem.leading;

}

catch (e) {

var theLeading = theLayer.textItem.size * 1.2;

};

var theOffset = 0;

// work off the array;

for (var m = 0; m < theText.length; m++) {

// duplicate layer, change its contents and move it;

var theNewText = theLayer.duplicate(theLayer, ElementPlacement.PLACEBEFORE);

theNewText.textItem.contents = theText[m];

theNewText.translate(0, theOffset);

// amend offset;

theOffset = theOffset+theLeading

}

}

};


Viewing all articles
Browse latest Browse all 27456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>