如何在 Photoshop 中拆分文本?

平面设计 adobe-photoshop 文本 层数
2022-01-07 19:21:26

我在 Photoshop 的文本层中有一个词。我希望每个角色都在一个单独的图层上,我该怎么做?

4个回答

这可以通过脚本功能来完成。

编辑:我已经在下面更新了我的答案,并经过了尝试和测试。

  • 打开任何文本编辑器
  • 将以下代码复制并粘贴到其中
  • 确保文本层的名称与第 20 行中定义的名称匹配
  • 另存为 splitText.jsx
  • 用 Photoshop 打开。还要确保要应用它的文档是当前活动的文档。

splitText.jsx 的内容

// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop

// in case we double clicked the file
app.bringToFront();

// debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning)
// $.level = 0;
// debugger; // launch debugger on next line

var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;

app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.POINTS;

var thisDocument = app.activeDocument;

// USE THIS LINE TO GRAB TEXT FROM EXISTING LAYER
var theOriginalTextLayer = thisDocument.artLayers.getByName("NAME-OF-LAYER");
var theTextToSplit = theOriginalTextLayer.textItem.contents;

// OR USE THIS LINE TO DEFINE YOUR OWN
// var theTextToSplit = "Hello";

// suppress all dialogs
app.displayDialogs = DialogModes.NO;

//  the color of the text as a numerical rgb value
var textColor = new SolidColor;
textColor.rgb.red = 0;
textColor.rgb.green = 0;
textColor.rgb.blue = 0;

var fontSize = 120;         // font size in points
var textBaseline = 480;     // the vertical distance in pixels between the top-left corner of the document and the bottom-left corner of the text-box

for(a=0; a<theTextToSplit.length; a++){ 
// this loop will go through each character

    var newTextLayer = thisDocument.artLayers.add();        // create new photoshop layer
        newTextLayer.kind = LayerKind.TEXT;             // set the layer kind to be text
    //  newTextLayer.name = textInLayer.charAt(a);

    var theTextBox = newTextLayer.textItem;             // edit the text
        theTextBox.font = "Arial";                      // set font
        theTextBox.contents = theTextToSplit.charAt(a); // Put each character in the text
        theTextBox.size = fontSize;                           // set font size
    var textPosition = a*(fontSize*0.7);

        theTextBox.position = Array(textPosition, textBaseline);                // apply the bottom-left corner position for each character
        theTextBox.color = textColor;

};

/* Reset */

app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
docRef = null;
textColor = null;
newTextLayer = null;

然后移动关于屁股的文本层

  1. 选择文字工具。
  2. 输入你的信。
  3. 复制图层。
  4. 选择新图层。
  5. 突出显示复制的字母并键入第二个字母。
  6. 根据需要重复。

除非你要打破“反建制主义”,否则这是更快的方法。

非常感谢 Adam Elsodaney 的剧本,这太棒了 - 但是,如果你和我一样,希望剧本能撕开单词而不是角色,你将不得不修改它。

这是拆分单词的相同脚本:

// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop

// in case we double clicked the file
app.bringToFront();

// debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning)
// $.level = 0;
// debugger; // launch debugger on next line

var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;

app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.POINTS;

var thisDocument = app.activeDocument;

// USE THIS LINE TO GRAB TEXT FROM EXISTING LAYER
var theOriginalTextLayer = thisDocument.activeLayer;
var theTextToSplit = theOriginalTextLayer.textItem.contents;

// OR USE THIS LINE TO DEFINE YOUR OWN
// var theTextToSplit = "Hello";

// suppress all dialogs
app.displayDialogs = DialogModes.NO;

//  the color of the text as a numerical rgb value
var textColor = new SolidColor;
textColor.rgb.red = 0;
textColor.rgb.green = 0;
textColor.rgb.blue = 0;

var fontSize = 120;         // font size in points
var textBaseline = 480;     // the vertical distance in pixels between the top-left corner of the document and the bottom-left corner of the text-box


var words = theTextToSplit.split(" ");

for(a=0; a < words.length; a++){ 
// this loop will go through each character

    var newTextLayer = thisDocument.artLayers.add();    // create new photoshop layer
        newTextLayer.kind = LayerKind.TEXT;             // set the layer kind to be text

    var theTextBox = newTextLayer.textItem;             // edit the text
        theTextBox.font = "Arial";                      // set font
        theTextBox.contents = words[a];                 // Put each character in the text
        theTextBox.size = fontSize;                     // set font size
    var textPosition = a*(fontSize*0.7);

        theTextBox.position = Array(textPosition, textBaseline);    // apply the bottom-left corner position for each character
        theTextBox.color = textColor;

};

/* Reset */

app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
docRef = null;
textColor = null;
newTextLayer = null;

只是为了澄清(我不知道,不得不谷歌它)

  1. 将其保存到文本文件(即带有扩展名的桌面.jsx
  2. 确保您的 Photoshop 中有名为的文本图层,textlayer并且该文件在 Photoshop 中打开。
  3. 双击文件。
  4. 利润。

编辑:对于某些 reson 双击并不总是有效,如果它没有,在 photohp 中转到 File > Scripts > Browse 并双击那里的文件。它会开始运行。

我只给我一分钱。您没有指定是否需要将新图层作为可编辑文本或只是栅格化图层,在后一种情况下您可以:

  1. 栅格化图层
  2. 围绕您的第一层进行选择
  3. 按 CTRL + SHIFT + J(或 CMD + SHIFT + J)将选区剪切到新图层
  4. 对每个字母重复步骤 2 和 3

同样,仅当您对栅格化图层感到满意时才执行此操作。如果您需要文本图层,请使用 Lauren Ipsum 答案,因为它可能是更快的方法。