Editing Existing Text Layer...
Hi,
I am running CS4 on Vista 64 bit and programming a PS script in Javascript...
I have trouble editing an existing layer in a .psd file that I open.
The script is fairly simple:
1. open .psd file
2. edit font size, content, alignment of the EXISTING text layer
--> Note: this EXISTING text layer has an existing LAYER STYLE applied
3. close file
Everything works fine except part 2. The reason why I edit this EXISTING text layer is, b/c it is already exactly positioned where it needs to be and the desired layer style is already applied...
Here's what I tried :
I. I thought since the layer is already a TEXT LAYER there is no need to define the TEXT properties again - I used this code:
var textLayer = docRef.layers['text layer']; // define the existing text layer to a var
docRef.activeLayer = textLayer;
textLayer.font = '_Aviano-Regular';
textLayer.size = 36;
textLayer.style = "Regular";
textLayer.antiAliasMethod = AntiAlias.SHARP;
textLayer.contents = "test change";
--> Problem: the script runs without an error but the changes are NOT applied...
II. I defined the existing text layer to be a TEXT LAYER - I used this code:
var textLayer = docRef.layers['text layer']; // define the existing text layer to a var
docRef.activeLayer = textLayer;
textLayer.kind = LayerKind.TEXT;
var T1 = textLayer.textItem;
T1.font = '_Aviano-Regular';
T1.size = 36;
T1.style = "Regular";
T1.antiAliasMethod = AntiAlias.SHARP;
T1.contents = "test change";
--> Problem: this applies the changes, BUT the actual text font size applied is 120 (!!!) - I have to multiply with 0.3 to actually get to 36 and this does not work all the time.... very, very strange.... I'm assuming this has to do with that we redefine an EXISTING text layer as a text item...
III. I though about...:
1. creating a NEW text layer
2. applying all my properties
3. then position it at the exact position where the EXISTING text layer is located
Problem: the creation and the styles (properties) work fine, BUT when I get the coordinates through .bounds and when I apply the [0] and [1] values it does NOT match the position (too high).... applying the [0] and [3] values does NOT mtach either (too low)... do I need to split the difference between those two ???
Thanx for your help in advance !!!
- M
