Turning point text into text along path in Illustrator

I have a lot of text objects in point format and would like to convert these to text paths (see images). Is this possible?

point text
text along path

Answer

Not sure how proficient you are with scripting, but here is a snippet which takes one point text item and turns it into a text path item.
You can ask here or on the Adobe Illustrator scripting forum, how to extend this snippet to do more complex operations – for example, right now it will throw errors for many things if the conditions are not just right.

#target illustrator
function test(){
  var doc = app.activeDocument;
  var t = doc.textFrames[0];
  var point = t.anchor;
  var width = t.width;
  var newPath = doc.pathItems.add();
  newPath.setEntirePath([[point[0], point[1]], [point[0] + width, point[1]]]);
  var newPathText = doc.textFrames.pathText(newPath);
  newPathText.contents = t.contents;
  t.remove();
};
test();

————————– EDIT #1 ————————-

#target illustrator
function test(){
  var doc = app.activeDocument;
  doc.selection = null;
  var t = doc.textFrames[0];
  var point = t.anchor;
  var width = t.width;
  t.selected = true;
  t.convertPointObjectToAreaObject();
  app.redraw();
  t = doc.selection[0];
  doc.selection = null;
  var tempTextPath = t.textPath;
  var angle = Math.atan2(tempTextPath.pathPoints[1].anchor[1] - tempTextPath.pathPoints[0].anchor[1], tempTextPath.pathPoints[1].anchor[0] - tempTextPath.pathPoints[0].anchor[0]) * 180 / Math.PI;

  var newPath = doc.pathItems.add();
  newPath.setEntirePath([[point[0], point[1]], [point[0] + width, point[1]]]);
  newPath.rotate(angle, undefined, undefined, undefined, undefined, Transformation.BOTTOMLEFT);
  var newPathText = doc.textFrames.pathText(newPath);
  newPathText.contents = t.contents;
  t.remove();
};
test();

————————– EDIT #2 ————————-

#target illustrator
function test(){
  function convertPointText(pointText){
    var doc = app.activeDocument;
    doc.selection = null;
    var t = pointText;
    var point = t.anchor;
    var width;
    var size = t.textRange.characterAttributes.size;
    t.selected = true;
    t.convertPointObjectToAreaObject();
    app.redraw();
    t = doc.selection[0];
    doc.selection = null;
    var tempTextPath = t.textPath;
    var angle = Math.atan2(tempTextPath.pathPoints[1].anchor[1] - tempTextPath.pathPoints[0].anchor[1], tempTextPath.pathPoints[1].anchor[0] - tempTextPath.pathPoints[0].anchor[0]) * 180 / Math.PI;
    t.rotate(-angle, undefined, undefined, undefined, undefined, Transformation.BOTTOMLEFT);
    width = tempTextPath.width;

    var newPath = doc.pathItems.add();
    newPath.setEntirePath([[point[0], point[1]], [Math.round(point[0] + width), point[1]]]);
    newPath.rotate(angle, undefined, undefined, undefined, undefined, Transformation.BOTTOMLEFT);
    var newPathText = doc.textFrames.pathText(newPath);
    newPathText.contents = t.contents;
    newPathText.textRange.characterAttributes.size = size;
    t.remove();
  };

  var doc = app.activeDocument;
  var sel = doc.selection;
  var workTextFramesArray = [];
  for (var i = 0; i < sel.length; i++) {
    workTextFramesArray[i] = sel[i];
  }
  for (var i = 0; i < workTextFramesArray.length; i++) {
    convertPointText(workTextFramesArray[i]);
  }
};
test();

Attribution
Source : Link , Question Author : oskarlin , Answer Author : Silly-V

Leave a Comment