Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: How do I find the font for a specific character in a textItem?

$
0
0

It got rid of my formatting, so it's a little harder to read, but fairly straightforward. Basically the parent for loop finds layers within the layerSet 'quoteLayer'. This is successfully grabbing contents for each text item, and pushing them to an array. Where I'm looking for more info, is how to tell the actionReference to get quoteLayer[n] as it's target, instead of the active Layer. Is it as simple as changing one of the values within ref.putEnumerated to charIDToTypeID(quoteLayer[n])?

 

for(n=0; n<quoteLayer.length; n++){
    if(quoteLayer[n].kind == LayerKind.TEXT) {
        quoteLineContents = quoteLayer[n].textItem.contents;
        arrayPush('quoteUsed',quoteLineContents)
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
        var layerDesc = executeActionGet(ref);
        var textDesc = layerDesc.getObjectValue((stringIDToTypeID('textKey'));
        var paragraphStyle = textDesc.getList(stringIDToTypeID('paragraphStyleRange'));
        var kernRange = textDesc.getList(stringIDToTypeID('kerningRange'));
        var rangeList = textDesc.getList(stringIDToTypeID('textStyleRange'));
        for (var m = 0; m < rangeList.count; m++) {
            var styleDesc = rangeList.getObjectValue(m).getObjectValue(stringIDToTypeID('textStyle'));
            try {fontName = styleDesc.getString(stringIDToTypeID('fontPostScriptName'))}
            catch (e) {fontName = "Error: Reformat text objects and try again"}  
            arrayPush ('fontsUsed',fontName);
        }
    }

Viewing all articles
Browse latest Browse all 27456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>