Has
anyone actually managed to create text objects in the new
scriptographer? I've looked through the docs endlessly, but the secret
is in the syntax obviously. If anyone has any rudimentary creation of
text, I'd really appreciate a little code posting!
Here's some sample code:
// the character style that we're going // to apply to the text var textStyle = new CharacterStyle(); textStyle.font = fonts["Times"]["Bold"]; textStyle.fontSize = 9; // the point where we're placing the text var textPos = new Point(20,30); // create the PointText item var text = new PointText(textPos); // put some content in the text item text.content = "Hi mom!"; //apply the characterstyle text.characterStyle = textStyle;
Yes it is, but the characterStyle is crashing Illustrator when I apply it to a text item.. I've submitted a bug report..
var textStyle = new CharacterStyle(); //set the fill color of the characterStyle textStyle.fill.color=CMYKColor(0,1,1,0); //we don't want a stroke on our text textStyle.stroke.color=Color.NONE;
Hi Jonathon --
Thanks for this. It's very similar to what I had written, but using setContent instead, and simply supplying x and y without creating a point var. I used older versions of scriptographer quite heavily, but have yet to get up to speed with the latest incarnation.
Excellent work by the way :) It's nice to see someone else with a typographical sensitivity and a programmers heart.
Yes, the old SG was not as picky about the format of parameters as the new one. E.g. wherever a point was expected, one could also just pass two values, or an array containing two values, etc. While this was nice in some parts, it increased confusion in others. Therefore I decided to get rid of it in the favour of a more strict API. I hope you wont miss that freedom...
May be I have the same problem ?
(http://www.scriptographer.com/Forum/Help/color-and-text/ ?)
MypointText.style.fill.color works but I can see the result ? I see color on stroke but not on fill...
var sel = activeDocument.getSelectedItems();
var colorz = new Array();
var count = -1;
colorz[0]=new RGBColor(0.5,0,1);
colorz[1]=new RGBColor(1,0,0);
for (var i = 0; i (colorz.length-1)){
var count = 0;
}
txt = sel[i];
print(txt);
if (txt instanceof PointText) {
var color = colorz[count];
if (txt.style.stroke.color != null) txt.style.stroke.color = color;
if (txt.style.fill.color != null) txt.style.fill.color = color;
}
}