Copy link to clipboard
Copied
Hi all,
I write the script of getting font size of the text layer. I am getting old font size after image resizing.
Following are the steps:
- I write the function to get the property of selected text layer..
getInfoOfText=function(textLayer)
{
........;
var textItem = textLayer.textItem;
var fontSize = textItem.size;
.........;
}
- After image resize to 50%. I am executing this function.
But, I am still getting old font size value.
Let's say the font size of text = 36 px.
Now I apply Image Resize to 50%. So, the font size of the text becomes 18 px.
Now If I execute the function "getInfoOfText", I am still getting 36 px.
I am unable to understand the behaviour. Am I missing something here? Is there any way to get the correct font size value?
Please note that I am using CS6 version.
Waiting for ur help guys.
Thanks
It seems that there is a BUG in CS6 and CC with transformed text, here is a function from http://www.ps-bridge-scripts.talktalk.net/
...function getFontSize(){
if(app.version.match(/^\d+/) < 13) return activeDocument.activeLayer.textItem.size;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('textKey'));
var textSize = desc.getList(stringIDToTypeID('textStyleRan
Copy link to clipboard
Copied
It seems that there is a BUG in CS6 and CC with transformed text, here is a function from http://www.ps-bridge-scripts.talktalk.net/
function getFontSize(){
if(app.version.match(/^\d+/) < 13) return activeDocument.activeLayer.textItem.size;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('textKey'));
var textSize = desc.getList(stringIDToTypeID('textStyleRange')).getObjectValue(0).getObjectValue(stringIDToTypeID('textStyle')).getDouble (stringIDToTypeID('size'));
if (desc.hasKey(stringIDToTypeID('transform'))) {
var mFactor = desc.getObjectValue(stringIDToTypeID('transform')).getUnitDoubleValue (stringIDToTypeID('yy') );
textSize = (textSize* mFactor).toFixed(2).toString().replace(/0+$/g,'').replace(/\.$/,'');
}
return textSize;
};
Copy link to clipboard
Copied
Thanks Philip for the response,
It is working.