Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Contributor ,
Sep 24, 2021 Sep 24, 2021

 

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.

 

Screenshot 2021-09-24 at 1.15.14 PM.png

 

Screenshot 2021-09-24 at 1.35.29 PM.png

TOPICS
Actions and scripting , macOS
7.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Explorer ,
Sep 24, 2021 Sep 24, 2021

Hi All,

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2021 Sep 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 24, 2021 Sep 24, 2021

Thanks Mack. Could you please explain in detail how to append the "world-ready layout" option in tool preset? and this new approach for me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 24, 2021 Sep 24, 2021

Activate the text tool in Photoshop set the font the paragraph options etc etc you want to be used with the text tool.  Once All is like you want to use the text tool. Create a new text tool preset.

Capture.jpg

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 27, 2021 Sep 27, 2021

I have tried, but I can't able to apply the preset for texts in the psd files. It's applied for newly created text after selecting the customized presets. Is it right?

 

 

Is it possible to apply the above via Action Manager Code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 27, 2021 Sep 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2021 Sep 27, 2021

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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 27, 2021 Sep 27, 2021

Now I have change my approach and created the Photoshop actions to apply "World Ready layout" and Diacritcs for specific Thai langauge. Now I'm trying to integrate the actions with the below javascript code. It apply the actions for first layer only and not apply for remaining text layers. Could you help me how to get rid out of this?

 

#target photoshop

loadActions();
digitalStyling()
unLoadActionSet("TH_Styling") 

function digitalStyling() {
    var Psd_Doc = app.activeDocument;
    for (var i=0; i<Psd_Doc.layers.length;i++) {
        var theLayer = Psd_Doc.layers[i];
        if (theLayer.typename == 'LayerSet') {
            var mySub_Layer = theLayer.layers;
            for (var j=0; j<mySub_Layer.length;j++) {
                if(mySub_Layer[j].kind == LayerKind.TEXT ) {
                    if(mySub_Layer[j].textItem) {
                        playAction("TH_Styling", "World-Ready-Layout")
                    }
                }
            }
        }
        else if (theLayer.typename == 'ArtLayer'){
            if(theLayer.kind == LayerKind.TEXT ) {
                if(theLayer.textItem) {
                    playAction("TH_Styling", "World-Ready-Layout")
                }
            }
        }
    }
}

function playAction(actionSet, actionName){
    var idPly = charIDToTypeID( "Ply " );
        var desc2 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref1 = new ActionReference();
            var idActn = charIDToTypeID( "Actn" );
            ref1.putName( idActn, actionName );
            var idASet = charIDToTypeID( "ASet" );
            ref1.putName( idASet, actionSet );
        desc2.putReference( idnull, ref1 );
    executeAction( idPly, desc2, DialogModes.NO );    
}

function loadActions () {
    var actionFile = File("~/Documents/Adobe Scripts/TH_Styling/TH_Styling.atn");
    if(!actionFile.exists){
        alert("Action file does not exist!");
        return;
    }else{
        app.load(actionFile);
    }
};

function unLoadActionSet(actionSet){
    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    ref.putName( charIDToTypeID( "ASet" ), decodeURI(actionSet));
    desc.putReference( charIDToTypeID( "null" ), ref );
    executeAction( charIDToTypeID( "Dlt " ), desc, DialogModes.NO );
};

 

For action file
TH_Styling.zip

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2024 Mar 29, 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 );
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 01, 2024 Jul 01, 2024
LATEST

how to use this code 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines