Answered
Text is overset text?
Hi Team,
Kindly let me know how to find text overset available in psd file using javascript/script listener.
Thanks
Hi Team,
Kindly let me know how to find text overset available in psd file using javascript/script listener.
Thanks
I practically don't work with text. I know very little about it. You can try this way.
var y1 = activeDocument.activeLayer.bounds[3].value;
var h = activeDocument.activeLayer.textItem.height;
activeDocument.activeLayer.textItem.height = 2*h;
var y2 = activeDocument.activeLayer.bounds[3].value;
activeDocument.activeLayer.textItem.height = h;
alert(y2-y1)
If the result y2-y1 is zero, then with a high probability we can say that all the text is visible.
Thanks!
I tried to follow up on the point text work-around.
// check if type layers in active document have overset text;
// 2021, use it at your own risk;
if (app.documents.length > 0) {
var theCheck = checkForOversetText ();
alert ("layers with index "+theCheck.join(", ")+" contain overset text")
};
////// check for overset texts //////
function checkForOversetText () {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));
var theArray = new Array;
// work through layers;
for (var m = theNumber; m >= 0; m--) {
try {
////////////////////////////////////
var someValues = someTextProperties(m);
if (someValues != false){
if (someValues[0] == "box"){
// convert to point type;
var desc01 = new ActionDescriptor();
var ref5 = new ActionReference();
ref5.putProperty( stringIDToTypeID( "property" ), stringIDToTypeID( "char" ) );
ref5.putIndex( stringIDToTypeID( "textLayer" ), m );
desc01.putReference( stringIDToTypeID( "null" ), ref5 );
desc01.putEnumerated( stringIDToTypeID( "to" ), stringIDToTypeID( "char" ), stringIDToTypeID( "paint" ) );
executeAction( stringIDToTypeID( "set" ), desc01, DialogModes.NO );
var otherValues = someTextProperties(m);
// undo;
activeDocument.activeHistoryState = activeDocument.historyStates[activeDocument.historyStates.length - 2];
// compare;
var theCheck = true;
var theNumber1 = 0;
var theNumber2 = 0;
while (theCheck == true && theNumber1 != someValues[1].length) {
var value1 = someValues[1][theNumber1];
var value2 = otherValues[1][theNumber2];
if (value1 != value2) {
switch (value2) {
case "\r":
theNumber1++;
theNumber2++;
break;
case "-":
theNumber2++;
theNumber2++;
break;
default:
theCheck = false;
break;
};
} else {
theNumber1++;
theNumber2++
}
};
if (theCheck == false) {theArray.push(m)}
else {};
}
};
////////////////////////////////////
}
catch (e) {};
};
// select layers;
if (theArray.length > 0) {
selectLayerByIndex(theArray[0],false);
for (var x = 1; x < theArray.length; x++) {
selectLayerByIndex(theArray[x],true)
}
};
// return results;
return theArray
};
////// check something //////
function someTextProperties (theIndex) {
try {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID( "property" ), stringIDToTypeID('textKey'));
ref.putIndex ( charIDToTypeID("Lyr "), theIndex);
var layerDesc = executeActionGet(ref);
var textDesc = layerDesc.getObjectValue(stringIDToTypeID('textKey'));
var theText = textDesc.getString(stringIDToTypeID('textKey'));
var textShape = textDesc.getList(stringIDToTypeID('textShape'));
var paragraph = typeIDToStringID(textShape.getObjectValue(0).getEnumerationValue(stringIDToTypeID('char')));
return [paragraph, theText]
} catch (e) {return false}
};
// by mike hale, via paul riggott;
function selectLayerByIndex(index,add){
add = undefined ? add = false:add
var ref = new ActionReference();
ref.putIndex(charIDToTypeID("Lyr "), index);
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID("null"), ref );
if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );
desc.putBoolean( charIDToTypeID( "MkVs" ), false );
try{
executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
}catch(e){
alert(e.message);
}
};
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.