デザイン関連(Photoshop・Illustrator)に関する各種メモ書き

IllustratorのJavascriptでテキスト、フォントを操作する

● IllustratorのJavascriptでテキスト、フォントを操作するには以下の例のようにします

// 1. 現在選択されているテキストがあるかどうかを判別する
selectedObj = activeDocument.selection;
if( selectedObj.length == 0 ){
	alert("選択されているテキストはありません");
}

// 2. 全てのテキストを走査し、textFontプロパティを表示する
frames = app.activeDocument.textFrames;
for(i=0; i < frames.length; i++){
	family   = frames[i].textRange.characterAttributes.textFont.family;
	style    = frames[i].textRange.characterAttributes.textFont.style;
	f_name   = frames[i].textRange.characterAttributes.textFont.name;
	size     = frames[i].textRange.characterAttributes.size;
	typename = frames[i].textRange.characterAttributes.typename;
	t_contents = frames[i].textRange.contents;
	alert("textFontプロパティ\n"+"family : "+family+"\nstyle : "+style+"\nname : "+f_name+"\nsize : "+size+"pt\n"+"typename : "+typename+"\n----- contents -----\n"+t_contents);
}

● テキストの色を変える

function change_fillcolor(obj,r,g,b)
{
	var my_color = new RGBColor();
	my_color.red   = r;
	my_color.green = g;
	my_color.blue  = b;
	obj.textRange.characterAttributes.fillColor  = my_color;		// 塗りの色を指定
}

function change_strokecolor(obj,r,g,b)
{
	var my_color = new RGBColor();
	my_color.red   = r;
	my_color.green = g;
	my_color.blue  = b;
	obj.textRange.characterAttributes.strokeColor = my_color;		// 線の色を指定
}

***■IllustratorのJavascriptでフォント(書体)を指定する http://www.openspc2.org/book/IllustratorCS/easy/039/index.html

***■【Illustrator】同フォント・同サイズのテキストオブジェクト選択 http://goo.gl/DQZew

***■ Adobe Illustrator CS5 Scripting Reference【CS 5 用リファレンスpdf】 http://goo.gl/doHXD

***■ Adobe Illustrator CS4 Scripting Reference【CS 4 用リファレンスpdf】 http://goo.gl/G7bRR

関連エントリー

No.787
01/19 21:04

edit

JavaScript
illustrator
フォント