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

Text is overset text?

Participant ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

Hi Team,

 

Kindly let me know how to find text overset available in psd file using javascript/script listener.

 

Thanks

TOPICS
Actions and scripting

Views

1.6K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , May 24, 2021 May 24, 2021

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"), charI
...

Votes

Translate

Translate
Adobe
Community Expert ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

Please elaborate. 

Votes

Translate

Translate

Report

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
Participant ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

Hi,

Kindly Review below snaps.

 

Screen Shot 2019-09-19 at 12.48.38.jpg

Some texts are hidden under the text item.

i need to write to automation scripts thats helps to shown overset documents names.

 

Thanks

Votes

Translate

Translate

Report

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 ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

Thanks.

 

I seem to recall past discussion/s on the issue though I couldn’t find the thread/s.

 

If you cannot identify a property in the AM code checking the text, then converting to Point Type and checking if the text is unchanged (and undoing the conversion, naturally) would provide a work-around.

 

 

The Strings of texts with more than one line cannot be identical because the line-breaks and the hyphens in the Point Text are letters, too, but by comparing letter for letter one can »filter« them out and determine if overset text exists.

One could then do that with all type layers in a document.

 

@Kukurykus , @r-bin , @jazz-y , please forgive the intrusion but at current you are the ones whose names come to my mind easily when it comes to Photoshop Scripting advice on this Forum; do any of you have a better idea or an immediate way of determining overset text in a Type Layer?

Votes

Translate

Translate

Report

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
LEGEND ,
May 23, 2021 May 23, 2021

Copy link to clipboard

Copied

I still don't understand what he wants 😉

Votes

Translate

Translate

Report

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 ,
May 23, 2021 May 23, 2021

Copy link to clipboard

Copied

I think he wants to determine (in bulk) which files contain Paragraph Type Text Layers with overset text (when the Type Layer's bounds are too smal to contain all the entered text). 

Screenshot 2021-05-23 at 14.05.56.pngScreenshot 2021-05-23 at 14.05.47.png

Votes

Translate

Translate

Report

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
LEGEND ,
May 23, 2021 May 23, 2021

Copy link to clipboard

Copied

I got it. Probably the 2 others you mentioned will help more as I saw them in action with this.

Votes

Translate

Translate

Report

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 ,
May 23, 2021 May 23, 2021

Copy link to clipboard

Copied

Thank you! 

I had done a Forum search here but I didn’t find a solution, maybe I should have checked over on PS-Scripts

Votes

Translate

Translate

Report

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
LEGEND ,
May 23, 2021 May 23, 2021

Copy link to clipboard

Copied

When from you're ACP? Months ago you weren't interested. What happened now you are?

Votes

Translate

Translate

Report

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
People's Champ ,
May 23, 2021 May 23, 2021

Copy link to clipboard

Copied

c.pfaffenbichler

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.

Votes

Translate

Translate

Report

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 ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

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); 
    }
    };

 

Votes

Translate

Translate

Report

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
Participant ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

Hi @c.pfaffenbichler 

Is there a way to alert the artboard names instead of the layer index? Thanks in advance. 

Votes

Translate

Translate

Report

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 ,
Aug 05, 2023 Aug 05, 2023

Copy link to clipboard

Copied

What good is the name? Do you want to »manually« identify the affected Layers in the Layers Panel afterwards? 

Wouldn’t it make more sense to just select all affected Layers (for which the index is useful)? 

Votes

Translate

Translate

Report

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
Participant ,
Aug 06, 2023 Aug 06, 2023

Copy link to clipboard

Copied

Yes, that's right @c.pfaffenbichler. I need to manually identify the affected Layers in the artboards and make changes accordingly. Selecting all affected layers using index is fine but along with it alerting the name of the artboard would be really helpful in my use case. 

Votes

Translate

Translate

Report

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 ,
Aug 06, 2023 Aug 06, 2023

Copy link to clipboard

Copied

LATEST
// 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 and name\n\n"+theCheck.join("\n\n")+"\n\ncontain 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, getLayerNameByIndex (m)])}
else {};
}
};
////////////////////////////////////
    }
    catch (e) {};
    };
// select layers;
if (theArray.length > 0) {
    selectLayerByIndex(theArray[0][0],false);
    for (var x = 1; x < theArray.length; x++) {
    selectLayerByIndex(theArray[x][0],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}
};
////// check something //////
function getLayerNameByIndex (theIndex) {
    try {
        var ref = new ActionReference();
        ref.putProperty(stringIDToTypeID( "property" ), stringIDToTypeID('name'));
        ref.putIndex ( charIDToTypeID("Lyr "), theIndex);
        var layerDesc = executeActionGet(ref);
        var theName = layerDesc.getString(stringIDToTypeID('name'));
        return theName
    } catch (e) {}
};
// 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); 
    }
    };

Votes

Translate

Translate

Report

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