Skip to main content
研藤2288657
Participating Frequently
January 12, 2021
質問

AppleScriptでフォントとの選択

  • January 12, 2021
  • 返信数 4.
  • 1536 ビュー

25.1にアップデートしたら、

今まで通っていたapplescriptの

set text font of characters to text font "FutoGoB101Pro-Bold" of application "Adobe Illustrator"

の最初の"のところで 「end of lineなどがあるべきところですが"""が見つかりましたと。」

エラーが返されるようになった。

このトピックへの返信は締め切られました。

返信数 4

Participating Frequently
January 16, 2021

少しわかりました。

「 text font 」を「 font 」にするとver25.1でもコンパイルできました。

 

set font of characters to font "FutoGoB101Pro-Bold" of application "Adobe Illustrator"

 

私が書いた to every font whose 〜 は必要なく、時間がかかりすぎますので、

これでいけば、ひとまず今回の件は今まで通りの構文で使えそうです。

ちなみにver25.1未満でコンパイルすると「 font 」は「 text font 」に自動で置き換わります。

研藤2288657
研藤2288657作成者
Participating Frequently
January 19, 2021

ありがとうございます。

repeat させるようなものではなかったので、 to every font whose 〜 でも font に変えるだけのものでも、そんなに時間差がなかったので、 to every font whose 〜 で行ってます。ただ、将来的に、 to every font whose 〜 別の問題引き起きそうでビクビクしています。

 

Participant
January 15, 2021

25.1はスクリプト関連の不具合が多そうです。

例えば以下のような単純なスタイル適用でエラーが発生します。(25.01では動作する)

tell application "Adobe Illustrator"
	tell document 1
		apply paragraph style paragraph style 1 to text of story of text frame 1
	end tell
end tell

処理内容はテキストフレーム1に標準段落スタイルを適用するというシンプルなものです。

困ったものですね。スクリプト機能全般において不具合修正が待たれます。

monokano
Community Expert
Community Expert
January 12, 2021
tell application "Adobe Illustrator"
	tell document 1
		set mySelObjList to selection
		repeat with mySelObj in mySelObjList
			if class of mySelObj is text frame then
				tell mySelObj
					set text font of characters to text font "FutoGoB101Pro-Bold" of application "Adobe Illustrator"
				end tell
			end if
		end repeat
	end tell
end tell

 

これで再現しました。2020ではOK、2021(v25.1.0)では構文エラー。

バグでしょうねぇ…。

「do javascript」にもバグがあるようですし、v25.1.0はAppleScript受難のバージョンかも。

https://community.adobe.com/t5/illustrator/applescript-do-javascript-command-no-longer-works-in-25-1/m-p/11737799?page=1&profile.language=en

Ten A
Community Expert
Community Expert
January 12, 2021

あらら?
わたしのところでは25.1.0で通っちゃいました…

なんだろう(^-^;

Participating Frequently
January 12, 2021

v25.1未満でコンパイルが通ったものは、v25.1でも通ってしまいますね。

 

  1. v25.1.0のみ起動
  2. スクリプトエディタを再起動
  3. スクリプトエディタの新規書類に(コンパイル済みのコードではなく)このページのコードをコピペ
  4. コンパイルボタンを押す

 

これで再現するはず。

 


つまり、コンパイルが出来ないわけですね、。

しかも、今までApple Scriptで動かないものはdo javascriptで対処してきましたが、それもダメですか、、。

これは直してくれないと、以前のverは今後のM1搭載Mac以降では動かなくなるでしょうし、Apple Scriptは諦め、Adobe Javascriptに移行していかないとダメそうですかね、、。

 

ひとまず、今回のサンプルスクリプトは、下記の方法でコンパイルできそうです。

text fontのプロパティに触らなければいいかも。

 

tell application "Adobe Illustrator"

set myTextFont to every font whose name is "FutoGoB101Pro-Bold"

set myTextFont to item 1 of myTextFont

tell document 1

set mySelObjList to selection

repeat with mySelObj in mySelObjList

if class of mySelObj is text frame then

tell mySelObj

set font of characters to myTextFont

end tell

end if

end repeat

end tell

end tell

Ten A
Community Expert
Community Expert
January 12, 2021

アプリケーションに添付されているサンプルを含め手持ちのASを検証してみましたが特に問題が出ませんでした。
アップデート時にスクリプトエンジン等に不具合が生じている可能性はありますが、スクリプト自体を見ないとなんとも言い難いところがあります。

研藤2288657
研藤2288657作成者
Participating Frequently
January 12, 2021

ありがとうございます。

スクリプトエディタでコンパイルできなくなったので???です。