アプリ版:「スタンプのみでお礼する」機能のリリースについて

WinXP上でPhotoshopCS2のJavaScriptのプログラムを書いています。
CS2に付いていたテキストレイヤーの設定例WorkingWithText.jsx
(添付)に1行足してフォントの設定を行おうとしたのですが、どうも
うまく動きません。エラーにはなりませんが、フォントの設定が無視されます。どのように書けばいいのか教えてください。
.....
newTextLayer.kind = LayerKind.TEXT;
newTextLayer.textItem.font = "Courier New"; ←この行を足しています。
newTextLayer.textItem.contents = "Hello, World!";
よろしくお願いします。


// Copyright 2002-2005. Adobe Systems, Incorporated. All rights reserved.
// Create a new art layer and convert it to a text layer.
// Set its contents, size and color.

// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop

// in case we double clicked the file
app.bringToFront();

// debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning)
// $.level = 0;
// debugger; // launch debugger on next line

var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.INCHES;
app.preferences.typeUnits = TypeUnits.POINTS;

var docRef = app.documents.add(7, 5, 72);

// suppress all dialogs
app.displayDialogs = DialogModes.NO;

var textColor = new SolidColor;
textColor.rgb.red = 255;
textColor.rgb.green = 0;
textColor.rgb.blue = 0;

var newTextLayer = docRef.artLayers.add();
newTextLayer.kind = LayerKind.TEXT;
newTextLayer.textItem.font = "Courier New";
newTextLayer.textItem.contents = "Hello, World!";
newTextLayer.textItem.position = Array(0.75, 0.75);
newTextLayer.textItem.size = 36;
newTextLayer.textItem.color = textColor;

app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
docRef = null;
textColor = null;
newTextLayer = null;

A 回答 (1件)

Courier New の PostScript 名は CourierNewPSMT なので


newTextLayer.textItem.font = "CourierNewPSMT";
としてみてはどうでしょうか。
    • good
    • 0
この回答へのお礼

回答いただき、ありがとうございます。
ご指摘の通りにしたら動きました!
フォント名は、メニューでの表示名ではなくて、
PostScript 名を設定する必要があるのですね。

お礼日時:2010/02/27 15:58

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!