Skip to main content
Known Participant
September 24, 2021
Question

To apply World -Ready layout & Diacritics through scripting or Action Manager Code

  • September 24, 2021
  • 2 replies
  • 8500 views

 

Hi All,

 

I have checked the Photoshop Object model for apply "World_ready layout " to all text layers in the .psd files, but I can't find any possibilites over there. Is it possible via Action manager code or scripting and also I want to apply Horizontal and Vertical Diacritics to be set to 0.

 

 

This topic has been closed for replies.

2 replies

Participating Frequently
March 30, 2024

I as able to get the code functions via ScriptingListener. Here is code for applying "World Ready Layout" & "Latin and East-Asian Layout":

setWorldReadyLayout();

function setWorldReadyLayout() {
  var descriptor = new ActionDescriptor();
  var descriptor2 = new ActionDescriptor();
  var reference = new ActionReference();

  reference.putProperty( stringIDToTypeID( "property" ), stringIDToTypeID( "paragraphStyle" ));
  reference.putEnumerated( stringIDToTypeID( "textLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ));
  descriptor.putReference( stringIDToTypeID( "null" ), reference );
  descriptor2.putEnumerated( stringIDToTypeID( "textComposerEngine" ), stringIDToTypeID( "textComposerEngine" ), stringIDToTypeID( "textOptycaComposer" )); // World-Ready Layout code
  descriptor.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "paragraphStyle" ), descriptor2 );
  executeAction( stringIDToTypeID( "set" ), descriptor, DialogModes.NO );
}

setLEALayout();

function setLEALayout() {
  var descriptor = new ActionDescriptor();
  var descriptor2 = new ActionDescriptor();
  var reference = new ActionReference();

  reference.putProperty( stringIDToTypeID( "property" ), stringIDToTypeID( "paragraphStyle" ));
  reference.putEnumerated( stringIDToTypeID( "textLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ));
  descriptor.putReference( stringIDToTypeID( "null" ), reference );
  descriptor2.putEnumerated( stringIDToTypeID( "textComposerEngine" ), stringIDToTypeID( "textComposerEngine" ), stringIDToTypeID( "textLatinCJKComposer" )); // Latin and East-Asian Layout code
  descriptor.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "paragraphStyle" ), descriptor2 );
  executeAction( stringIDToTypeID( "set" ), descriptor, DialogModes.NO );
}
Participant
July 1, 2024

how to use this code 

 

Known Participant
September 24, 2021

Hi All,

 

Is there any way to enable the world-ready layout in the photoshop document via any scripting language

JJMack
Community Expert
Community Expert
September 24, 2021

Try setting up a Text Tool Preset with that option set and select that preset in your script after activating the text tool it should work.

 

Script and actions can do very little when it come to setting  Photoshop UI options.  

JJMack
JJMack
Community Expert
Community Expert
September 27, 2021

I have tried the same with photoshop actions, it will apply the "World-Ready layout", but it will change all other properties into text which is used for recorded the action. Is it possible in Photo action to change the only one property as I want?


Script do not have an easy way to change  Photoshop UI tools options with Adobe DOM code.  However someone recently in the past few days posted a script that can toggle some tool sampling mode options. What you want to do may be possible from reading that script code there seems to be a current tool option object. So  you may be  able to retrieve the text tool current options  set the world in the object the  commit the change to the current text layer you are editing.  You need to know how Action Manager code works. That is above my pay grade. I just hack a little at Photoshop scripting. I do not actually know javascript....

// get current tool options object
function getCTO(){
    var ref = new ActionReference();
        ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("currentToolOptions"));
        ref.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
        return executeActionGet(ref).getObjectValue(stringIDToTypeID("currentToolOptions"));
}
// setting currentToolOptions with options array
function setCTO( options, isIdTypeString ){
    var desc = new ActionDescriptor();
        var ref = new ActionReference();
            ref.putClass( stringIDToTypeID( app.currentTool ) );
        desc.putReference( stringIDToTypeID( "target" ), ref );
        // getting current tool options so that they do not get reset
        var ctoObj = getCTO();
            // check if we are setting the eyedropper tool
            if ( app.currentTool=="eyedropperTool" ){
                ctoObj.putInteger( stringIDToTypeID( options[0][0] ), options[0][1] );
            } else {
                // iteration through options array and putting booleans into cto descriptor
                for (var i=0; i < options.length; i++){
                    if (isIdTypeString==true){
                        ctoObj.putBoolean( stringIDToTypeID( options[i][0] ), options[i][1] );
                    } else {
                        ctoObj.putBoolean( charIDToTypeID( options[i][0] ), options[i][1] );
                    }
                }
            }
        desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "currentToolOptions" ), ctoObj );
    executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO );
}

 

JJMack