fillChar - function to fill range of char

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

took

fillChar - function to fill range of char

Post by took »

fillChar - function to fill range of char in active text layer

function fillChar (from, to, c,m,y,k)
from - first symbol
to - finish symbol

c,m,y,k - CMYK color cmponents


Code: Select allfillChar - function to fill range of char in active text layer

function fillChar (from, to, c,m,y,k){
pntSize = app.activeDocument.activeLayer.textItem.size
typeFont = app.activeDocument.activeLayer.textItem.font
var id2025 = charIDToTypeID( "setd" );
    var desc117 = new ActionDescriptor();
    var id2026 = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var id2027 = charIDToTypeID( "TxLr" );
        var id2028 = charIDToTypeID( "Ordn" );
        var id2029 = charIDToTypeID( "Trgt" );
        ref26.putEnumerated( id2027, id2028, id2029 );
    desc117.putReference( id2026, ref26 );
    var id2030 = charIDToTypeID( "T   " );
        var desc118 = new ActionDescriptor();
        var id2086 = charIDToTypeID( "Txtt" );
            var list18 = new ActionList();
                var desc123 = new ActionDescriptor();
                var id2087 = charIDToTypeID( "From" );
                desc123.putInteger( id2087, from );
                var id2088 = charIDToTypeID( "T   " );
                desc123.putInteger( id2088, to );
                var id2089 = charIDToTypeID( "TxtS" );
                    var desc124 = new ActionDescriptor();
                    var id1483 = stringIDToTypeID( "fontPostScriptName" );
                    desc65.putString( id1483, typeFont );
                    var id1488 = charIDToTypeID( "Sz  " );
                    var id1489 = charIDToTypeID( "#Pnt" );
                    desc124.putUnitDouble( id1488, id1489, pntSize );                   
                    var id2173 = charIDToTypeID( "Clr " );
                        var desc125 = new ActionDescriptor();
                        var id2174 = charIDToTypeID( "Cyn " );
                        desc125.putDouble( id2174, c );
                        var id2175 = charIDToTypeID( "Mgnt" );
                        desc125.putDouble( id2175, m );
                        var id2176 = charIDToTypeID( "Ylw " );
                        desc125.putDouble( id2176, y );
                        var id2177 = charIDToTypeID( "Blck" );
                        desc125.putDouble( id2177, k );
                    var id2178 = charIDToTypeID( "CMYC" );
                    desc124.putObject( id2173, id2178, desc125 );
                    var id2185 = charIDToTypeID( "Fl  " );
                    desc124.putBoolean( id2185, true );
                var id2201 = charIDToTypeID( "TxtS" );
                desc123.putObject( id2089, id2201, desc124 );
            var id2202 = charIDToTypeID( "Txtt" );
            list18.putObject( id2202, desc123 );
        desc118.putList( id2086, list18 );
    var id2606 = charIDToTypeID( "TxLr" );
    desc117.putObject( id2030, id2606, desc118 );
executeAction( id2025, desc117, DialogModes.NO );
}