Skip to main content
Participant
February 26, 2013
Question

TextItem.size is wrong after transform (CS 6)

  • February 26, 2013
  • 1 reply
  • 4840 views

Hey, i've a export script for Photoshop, which creates a XML file.

On field in this XML is the font size for each text layer. But the .size value is wrong when we transform the text layer.

Example and steps to reproduce:

  1. create a text layer
  2. set font size 6pt (font family doesn't matter)
  3. TextItem.size will export "6 pt"
  4. transform the text - make it larger
  5. Photoshop shows for example "12 pt" as the font size
  6. TextItem.size still exports "6 pt"

Is there any way to get the correct font size?

When transforming text, you will get a value like "11.9999 pt" (you mostly don't get a round number).

But when you try to set the font size to 12 pt manually, TextItem.size still exports the old value.

The exporter works great in CS 3, the font sizes are correct. But in CS 6 its wrong.

Is this a PS bug maybe?

Alex

This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
February 26, 2013

Have a look at this thread...

http://forums.adobe.com/message/4902706

Participant
February 26, 2013

Hey Paul, thanks for that. Is it also possible to use it for multiple layers?

And does it work also for saved and reopend PSD files?

Alex

Inspiring
December 13, 2013

Michael L Hale wrote:

The short answer is no, you can not access the text transform value using the DOM. The snarky answer is actionDescriptor, actionReference, etc are DOM objects and executeAction is a DOM method so you can.

Ok, fair enough. Is the documentation on what's available to do pretty much exclusively here and on ps-scripts, or is there actual documentation somewhere that I somehow haven't found on what actions are available and what properties they take? I modified the above script to take a layer by name and just sort of had to guess at what to put in (I'd assumed that I wanted to use 'LyrN' instead of 'Lyr ' but was wrong, for example); I'd like to get deeper into scripting Photoshop in clever ways but it seems a lot like trial and error (especially since the error you get is something to the effect of, "something went wrong or maybe this version of Photoshop doesn't support what you were trying to do"). Thankfully the iteration loop isn't too long but it sure would be nice to be able to use var declarations in the console. 

Edit: oh sorry, it wasn't the above script that I edited but it was one similar that showed how to get the actual text size from the reported size * transform.yy.


I agree that the official documentation on using Action Manager in javascript is poor to non-existent so your best source is the user forums. I think PS-Scripts is better but I'll admit to being biased about that.

If you wanted to reference a layer by name and the code you have references by index and you have a line that reads

ref.putIndex( charIDToTypeID( 'Lyr ' ), i );// class,index property

If you look in the javascript reference under ActionReference you see that putIndex has two arguments. The first is the class and the second it the index as a number. The charID 'LyrN' does map to the stringID 'layerName'. But name is a property so would be used where a class ID is required. Instead you  change the method to putName and it will use the name instead of the index.

ref.putName( charIDToTypeID( 'Lyr ' ), layerNamei );// class,name properry

Making a guess about which ID to use is never a good idea but I will admit that I have done that more than once.

It is also true that the error messages are long longer very helpful. At one time Photoshop did have much better error messages for what caused the error. Not they might as well just say 'Error'.