Copy link to clipboard
I've written some code to add a generic "order number" textFrame to each piece of a garment (so that the garments can be tracked easier in production). We use an automated cutting system that reads a stroke in the document called "Thru-cut". since anything outside this line will be cut off, i need to make sure my order number text is INSIDE the thru-cut line.
I'm essentially just duplicating the thru-cut path and then utilizing it as a textPath so that the order number text will follow along the line wherever it may be.. However, I'm finding completely unpredictable results with the "evenOdd" property of the textPath... In theory, setting pathText.evenOdd = true; should place the text on the "inside" of the line.... which.. in some cases, it does... However, it seems wildly inconsistent. I could see an issue where two paths that are completely different shapes might have different results... but I'm seeing variable results between two pieces that are the exact same shape, just a slightly different size. There should be no difference in the ray casting... but the result is different..
I've tried all combinations of opened/closed paths with evenOdd true/false... and no matter what i do, the results are inconsistent.. and some shapes will get the text on the outside of the line 100% of the time no matter what i do...
What the heck? How does textPath.evenOdd work? How can i guarantee that my text will end up on the "inside" of the path?
Here's a screenshot showing 2 pieces with differing results:
And here's a screenshot of the shape for which i can NEVER get the text on the inside of the line no matter what i try:
Copy link to clipboard
My understanding is that the even–odd rule in Illustrator relates specifically to fills and specifically to compound paths. So it doesn't apply here.
Also, my understanding is that pathText is always upright in relation to the left to right direction of the path. So if it's upside-down, it because the path's direction is right to left. It cannot be flipped with scripting. However, it can be moved above or below the path by shifting the baseline.
var doc = app.activeDocument; var path1 = doc.pathItems.add(); // path 1 is left to right (frame1 will be upright) path1.setEntirePath([[0, - 25], [100, - 25]]); var path2 = doc.pathItems.add(); // path 2 is right to left (frame2 will be upside-down) path2.setEntirePath([[100, - 75], [0, - 75]]); var path3 = doc.pathItems.add(); // path 3 is left to right (frame3 will be upright) path3.setEntirePath([[0, - 125], [100, - 125]]); var frame1 = doc.textFrames.pathText(path1); var frame2 = doc.textFrames.pathText(path2); var frame3 = doc.textFrames.pathText(path3); // baseline shifted below path 3 frame3.textRange.characterAttributes.baselineShift = - 10; frame3.contents = frame2.contents = frame1.contents = "ABCDE";
I understand that evenOdd is also used for filling paths, but it is also a property of the textPath object. documentation here:
I'll try reversing the path and see if that does it.. Thanks, Femke 😃
Sorry, I didn't see that. It's unclear to me what it's supposed to do.
the shape you never get the text on the inside has a Positive Polarity, I changed it to Negative and the text flipped and went to the inside
selection.textPath.polarity = PolarityValues.NEGATIVE;
similar to going to Type->Type On a Path...Flip
another alternative, you could do an offset path, so it's guaranteed the text will be on the inside and then change the "Align to Path" option from Baseline to Center. This can be done with an action.
polarity did the trick. thanks carlos!