Copy link to clipboard
Copied
Hello every one~
I have a question...
Is it possible to access or get information from these items via script? I tried to find out but the results say it is not possible.
This may help get you started.
// type layer properties;
// based on code by michael l hale;
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID('textKey'));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var textDesc = layerDesc.getObjectValue(stringIDToTypeID('textKey'));
checkDesc2 (textDesc, true
...
Copy link to clipboard
Copied
That needs AM code, maybe the sources you referred to concerned DOM code.
Copy link to clipboard
Copied
Sorry, but what is AM code? I'm using extend script to get them.
Copy link to clipboard
Copied
Action Manager code, like the one created by ScriptingListener.plugin
Copy link to clipboard
Copied
This may help get you started.
// type layer properties;
// based on code by michael l hale;
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID('textKey'));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var textDesc = layerDesc.getObjectValue(stringIDToTypeID('textKey'));
checkDesc2 (textDesc, true);
// check kerning list;
var theCollection = new Array;
var kerningList = textDesc.getList(stringIDToTypeID('kerningRange'));
for (var o = 0; o < kerningList.count; o++) {
var thisList = checkDesc2(kerningList.getObjectValue(o), false);
theCollection.push(thisList);
};
alert ("kerning ranges\n"+theCollection.join("\n"))
// check ligature;
var theResults = new Array;
var aList = textDesc.getList(stringIDToTypeID('textStyleRange'));
for (var o = 0; o < aList.count; o++) {
var thisList = checkDesc2(aList.getObjectValue(o), false);
var ligature = aList.getObjectValue(o).getObjectValue(stringIDToTypeID('textStyle')).getBoolean(stringIDToTypeID('ligature'));
theResults.push(thisList+"ligature "+ligature+"\n");
};
alert ("results\n"+theResults.join("\n"))
};
//////
////// based on code by michael l hale //////
function checkDesc2 (theDesc, theAlert) {
var c = theDesc.count;
var str = '';
for(var i=0;i<c;i++){ //enumerate descriptor's keys
str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
};
if (theAlert == true) {alert("desc\n\n"+str);
return};
return str
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.ALIASTYPE:
return theDesc.getPath(theDesc.getKey(theNumber));
break;
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.RAWTYPE:
return theDesc.getReference(theDesc.getData(theNumber));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default:
break;
};
};
Copy link to clipboard
Copied
Thank you, i'll try it.
Copy link to clipboard
Copied
The second alert the Script provides would give a list of the kerning of the active Layer; but you should be able to adapt the Script to access other properties.
Copy link to clipboard
Copied
Got it, thank you!
Copy link to clipboard
Copied
I updated the code to include an alert about the ligature-setting (the »fi«-icon).
In this example I checked ligature and then unchecked if for three words in the Type Layer.
Copy link to clipboard
Copied
Thanks for the help, I will continue researching from here (and will come back if I still haven't reached my goal xD)
Copy link to clipboard
Copied
I don’t know what the »tsume«-setting does, I suspect I don’t use fonts that utilize that option.
Good luck!