当前位置: 代码迷 >> 综合 >> illustrator插件--脚本插件集合--常用插件介绍--文本编辑--段落合并--文字转曲--单行拆单字
  详细解决方案

illustrator插件--脚本插件集合--常用插件介绍--文本编辑--段落合并--文字转曲--单行拆单字

热度:20   发布时间:2024-02-25 02:07:23.0

??illustrator是矢量编辑软件,在创建矢量作品时,不可避免的会遇到文字处理方面的问题,如文本段落分行,段落行合并,文本段落转换,单行拆单字,字体转曲和大小写转换。便捷操作可以提高工作效率。如文本段落分行和字体转曲源代码如下所示:

//文本段落分行
if (activeDocument.selection[0].contents.indexOf("\n") != -1) {
    } else {
    var lineArr = fieldToArray(activeDocument.selection[0]);tfTop = activeDocument.selection[0].top;tfLeft = activeDocument.selection[0].left;activeDocument.selection[0].contents = lineArr[0];var tr = activeDocument.selection[0].story.textRange;var vSpacing = tr.leading;for (var j = 1; j < lineArr.length; j += 1) {
    bob = activeDocument.selection[0].duplicate(activeDocument, ElementPlacement.PLACEATBEGINNING);bob.contents = lineArr[j];bob.top = tfTop - (vSpacing * j);bob.left = tfLeft;bob.selected = false;}
}
function fieldToArray(myField) {
    if (myField.typename == "TextFrame") {
    retChars = new Array("", "", "\r", "\n");var ct = 0;var tmpTxt = myField.contents.toString();for (var all in retChars) {
    tmpArr = tmpTxt.split(retChars[all]);ct += tmpArr.length;}ct += 1;while (ct > 0) {
    tmpTxt = tmpTxt.replace(/[\x03]|[\f]|[\r\n]|[\r]|[\n]/, "_:X:_");ct--;}return tmpTxt.split("_:X:_");}
}//字体转曲
function outlineDocText() {
    if (app.documents.length == 0) {
    return;}var docRef = app.activeDocument;recurseLayers(docRef.layers);
}
outlineDocText();function recurseLayers(objArray) {
    for (var i = 0; i < objArray.length; i += 1) {
    var l = objArray[i].locked;if (l) {
    objArray[i].locked = false}var v = objArray[i].visible;if (!v) {
    objArray[i].visible = true}outlineText(objArray[i].textFrames);if (objArray[i].layers.length > 0) {
    recurseLayers(objArray[i].layers);}if (objArray[i].groupItems.length > 0) {
    recurseGroups(objArray[i].groupItems);}objArray[i].locked = l;objArray[i].visible = v;}
}function recurseGroups(objArray) {
    for (var i = 0; i < objArray.length; i += 1) {
    var l = objArray[i].locked;if (l) {
    objArray[i].locked = false}var h = objArray[i].hidden;if (h) {
    objArray[i].hidden = false}outlineText(objArray[i].textFrames);if (objArray[i].groupItems.length > 0) {
    recurseGroups(objArray[i].groupItems);}objArray[i].locked = l;objArray[i].hidden = h;}
}function outlineText(objArray) {
    for (var i = objArray.length - 1; i >= 0; i--) {
    var l = objArray[i].locked;if (l) {
    objArray[i].locked = false}var h = objArray[i].hidden;if (h) {
    objArray[i].hidden = false}var g = objArray[i].createOutline();g.locked = l;g.hidden = h;}
}

??页面如下图所示:
在这里插入图片描述
??合理的脚本代码可以有效的提高工作效率,减少重复劳动。


??欢迎光临知了软件开发网络平台,本公司定制开发各类软件,主要方向为桌面专业软件开发和插件定制开发,桌面软件主要包括文字图形识别类软件,信息管理类软件,3D打印类软件,视频类软件以及其它涉及专业的各类图形图像处理软件。插件包含AE插件,AI插件,PS插件,PDF插件,3DMAX插件以及Word,Excel等Office插件开发。详情请咨询,微信QQ:312117271,手机:18928899728,邮箱: anjingzhi_sea@163.com.
公司网址:http://www.zhiliaos.com