Copy link to clipboard
Copied
Hi,
I need a little help..
I want to get the Font size as a value wich is set in Photoshop is that possible?
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Text layers can also have a mixture of text font size and more than a single font. Text is very complex.
Copy link to clipboard
Copied
Is there any way to get this value from here without a text layer?
Copy link to clipboard
Copied
I do not think there would be any way to retrieve field values in all the different tools option bars. I could be wrong if the text tools is the current selected tool. For I know script cans get at some current brush tools setting of some brush types. Photoshop brushes support is very complex , Photoshop Text tool is very complex as well. Action Manager code would need to be used and the get refence part of action manager code requires a lot of knowledge about the ways Photoshop works. I count on r-bin to help me out in that area.
Why do you need that value if there is no text layer you can most likely set the tool up anyway you want?
Copy link to clipboard
Copied
// 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)}
Copy link to clipboard
Copied
PSA: this also grabs the incorrect size from a transformed layer
Copy link to clipboard
Copied
sTT = stringIDToTypeID, tK = sTT('textKey');
(ref = new ActionReference()).putProperty(sTT('property'), tK)
ref.putEnumerated(sTT('textLayer'),sTT('ordinal'),sTT('targetEnum'))
executeActionGet(ref).getObjectValue(tK).getObjectValue
(sTT('transform')).getDouble(sTT('yy')) // * size
Copy link to clipboard
Copied
@Kukurykus sorry i didn't see this until recently.
attached (as txt) is my basic test to use this code.
maybe i'm using it wrong, because I'm getting undefined for the transform value expected.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@Kukurykus I'd like to apply this transform to get the accurate textItem width and height (for paragraph type). Can't really go to the post I made earlier because we broke the page, so I'll put it here.
What I'm seeing is an accurate width, but the height always usually differs by 7-13% regardless of whether there is a transform on the text.