Sg2.9
PointText... arrrgghh!
Recent RSS
PointText... arrrgghh!
From:  moreducks!
Date:  24. March 2007, 19:22

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!

Re: PointText... arrrgghh!
Date:  25. March 2007, 14:37

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;
Re: PointText... arrrgghh!
From:  Jirka
Date:  25. March 2007, 15:28

is it possible to assign a color to the generated text independently on which color is currently used in the color picker?

Re: PointText... arrrgghh!
Date:  25. March 2007, 16:22

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;
Re: PointText... arrrgghh!
From:  moreducks!
Date:  25. March 2007, 17:08

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.

Re: PointText... arrrgghh!
From:  Jürg Lehni
Date:  25. March 2007, 20:05

It shouldn't make a difference if you use setContent(...) or content = ...
Also, you don't need to create the point var. You can also diretly create the text object like this:

var text = new PointText(new Point(x, y));
Re: PointText... arrrgghh!
From:  moreducks!
Date:  25. March 2007, 21:26

I see. I had written PointText(x,y);

ta

Re: PointText... arrrgghh!
From:  Jürg Lehni
Date:  26. March 2007, 03:35

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...

Re: PointText... arrrgghh!
From:  Jürg Lehni
Date:  26. March 2007, 05:51

I just fixed the bug reported by Jonathan. This will be in 2.0.023, to be released this week.

Re: PointText... arrrgghh!
Date:  26. March 2007, 09:29

Thanks Juerg!

Re: PointText... arrrgghh!
From:  ben
Date:  26. March 2007, 14:17

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;
}
}

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Stroke 3D 16.06.09