Skip to main content
Innotex Nico Tanne
Inspiring
October 28, 2019
Question

Read Font size with script

  • October 28, 2019
  • 1 reply
  • 3337 views

Hi,

 

I need a little help..

I want to get the Font size as a value wich is set  in Photoshop is that possible?

This topic has been closed for replies.

1 reply

Chuck Uebele
Community Expert
Community Expert
October 28, 2019

One warning about getting font size: if the layer has been transformed, you will get an incorrect reading of the size.

You can try this:

var tLayer = activeDocument.activeLayer;

alert(tLayer.textItem.font.size);

JJMack
Community Expert
Community Expert
October 28, 2019

Text layers can also have a mixture of text font size and more than a single font. Text is very complex.

 
JJMack
greless
Inspiring
October 29, 2019

Is there any way to get this value from here without a text layer?


// select tool
app.currentTool="typeCreateOrEditTool";

try{
var r = new ActionReference();
var d = new ActionDescriptor();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
r.putEnumerated(charIDToTypeID("capp"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var options = executeActionGet(r);
var object = options.getObjectValue(stringIDToTypeID("currentToolOptions")).getObjectValue(stringIDToTypeID("textToolCharacterOptions")).getObjectValue(stringIDToTypeID("textStyle"));


alert(object.getUnitDoubleValue(stringIDToTypeID("size")));
}
catch(e){alert(e)}