Photoshop: Each line of text to a new layer shortcut?

  • 1
  • Question
  • Updated 5 months ago
  • (Edited)
I have text in Arabic that is already typed. I want each line of text on a new layer. So I am looking for an easiest way to do this. Is there any hack to do this? Thanks!
Photo of Maseed Maseed

Maseed Maseed

  • 2 Posts
  • 0 Reply Likes

Posted 5 months ago

  • 1
Photo of Max Johnson

Max Johnson, Champion

  • 624 Posts
  • 338 Reply Likes
Only thing I can think of would be to record an action... first create a layer mask on your text layer and make sure you have the layer selected then record this action with a hotkey, like f5
  1. Duplicate the layer
  2. Delete the existing layer mask
  3. move layer down so next line matches with bottom line
  4. marquis select bottom line
  5. make new layer mask from selection.
Then you can select a text layer and mash the f5 key for every line. Then you'll still need to move the top and bottom layers into plabe and redistribute the lines again with Layer->Distribute->Vertical Centers

Photo of David

David, Official Rep

  • 3602 Posts
  • 615 Reply Likes
I'd just select your existing layer.  Copy it how every many number of times.  Then erase the text on previous lines, adding RETURNS to make sure the words wrap/space correctly.

Now, all that said, why would you want to do that?  Have you tried the Kashida functionality to change Tatwiil length?  It's actually a pretty cool feature and a couple of the settings are designed to make the geometry of different lines of text smoother too.

Thanks,
David
Photo of David Converse

David Converse

  • 939 Posts
  • 275 Reply Likes
If this is text in an existing text layer, it can be done with a script. If its text in a file, it can also be done (a bit differently) with a script.
Photo of David Converse

David Converse

  • 939 Posts
  • 275 Reply Likes
If your text is in a text file, this is a sample script to add it line by line to text layers.

--------------------------
#target photoshop

addText();

function addText(){
    if(documents.length > 0){
        var originalDialogMode = app.displayDialogs;
        app.displayDialogs = DialogModes.ERROR;
        var originalRulerUnits = preferences.rulerUnits;
        preferences.rulerUnits = Units.PIXELS;
        try{
            var testFile = new File('~/Desktop').openDlg('Select import file', '*.txt'); //select text file
            if(testFile != null){ //catch user cancel
                testFile.open('r');
                var textLine = testFile.readln();
                var docRef = activeDocument;
                var LayerRef = null;
                var TextRef = null;
                var pos = 200;
                while(textLine != ''){ //read in text one line at a time
                    LayerRef = docRef.artLayers.add();
                    LayerRef.kind = LayerKind.TEXT; //new text layer
                    TextRef = LayerRef.textItem;
                    TextRef.contents  = textLine; //text from file
                    //optional text styling, customize to suit
                    pos = pos + 50;
                    TextRef.position = new Array(pos, pos);
                    preferences.rulerUnits = Units.POINTS;
                    TextRef.size = 48;
                    TextRef.useAutoLeading = false;
                    TextRef.leading = 48;
                    TextRef.font = 'Calibri-Bold';
                    TextRef.justification = Justification.CENTER;
                    TextRef.autoKerning = AutoKernType.METRICS;
                    //end optional text styling
                    textLine = testFile.readln(); //read the next line from file
                    }
                testFile.close();
                }
            }
        catch(e){
            alert(e + e.line);
            preferences.rulerUnits = originalRulerUnits;
            app.displayDialogs = originalDialogMode;
            return;
            }
        preferences.rulerUnits = originalRulerUnits;
        app.displayDialogs = originalDialogMode;
        }
    else{
        alert('You must have a document open to run this script.');
        return;
        }
    return;
    }

(Edited)