5 Replies Latest reply on Aug 7, 2017 2:50 PM by hardestfred

    Insert text in freeform path

    hardestfred

      Hi,

      Is there a way to programatically (js/jsx) insert text into a closed freeform path and/or on a freeform line  ?

      When doing it manually, one would use the freeform pen tool, and switch to the type tool, then the cursor would change to this :

      170804-0002.png

      Or this :

      170804-0003.png

       

      I already know how to create a text layer based on a rectangular selection marquee (app.activeDocument.selection.makeWorkPath, get the anchors, find their positions, compute the size, etc...) but I found absolutely nothing concerning freeform paths. Or maybe I didn't use the correct keywords for the queries.

       

      Any help would be appreciated.

      Cheers.

        • 1. Re: Insert text in freeform path
          Jarda Bereza Level 4

          I think you will need

          1) read text layer descriptor

          2) read path descriptor

          3) add path descriptor into text descriptor

          4) apply modified text descriptor on text layer

          5) remove old path

           

          Use script listener and compare descriptors with and without paths.

          • 2. Re: Insert text in freeform path
            Jarda Bereza Level 4

            First you get text descriptor and it will contains all of this with diffirent values except lines from 84 to 186

            Then you take path descriptor and you will put this descriptor into another descriptor and you will add some extra info about where text will start orientation ect.

            So your data structure would look like this.

             

             

            var idMk = charIDToTypeID( "Mk  " );
                var desc2620 = new ActionDescriptor();
                var idnull = charIDToTypeID( "null" );
                    var ref1369 = new ActionReference();
                    var idTxLr = charIDToTypeID( "TxLr" );
                    ref1369.putClass( idTxLr );
                desc2620.putReference( idnull, ref1369 );
                var idUsng = charIDToTypeID( "Usng" );
                    var desc2621 = new ActionDescriptor();
                    var idTxt = charIDToTypeID( "Txt " );
                    desc2621.putString( idTxt, """test""" );
                    var idwarp = stringIDToTypeID( "warp" );
                        var desc2622 = new ActionDescriptor();
                        var idwarpStyle = stringIDToTypeID( "warpStyle" );
                        var idwarpStyle = stringIDToTypeID( "warpStyle" );
                        var idwarpNone = stringIDToTypeID( "warpNone" );
                        desc2622.putEnumerated( idwarpStyle, idwarpStyle, idwarpNone );
                        var idwarpValue = stringIDToTypeID( "warpValue" );
                        desc2622.putDouble( idwarpValue, 0.000000 );
                        var idwarpPerspective = stringIDToTypeID( "warpPerspective" );
                        desc2622.putDouble( idwarpPerspective, 0.000000 );
                        var idwarpPerspectiveOther = stringIDToTypeID( "warpPerspectiveOther" );
                        desc2622.putDouble( idwarpPerspectiveOther, 0.000000 );
                        var idwarpRotate = stringIDToTypeID( "warpRotate" );
                        var idOrnt = charIDToTypeID( "Ornt" );
                        var idHrzn = charIDToTypeID( "Hrzn" );
                        desc2622.putEnumerated( idwarpRotate, idOrnt, idHrzn );
                    var idwarp = stringIDToTypeID( "warp" );
                    desc2621.putObject( idwarp, idwarp, desc2622 );
                    var idTxtC = charIDToTypeID( "TxtC" );
                        var desc2623 = new ActionDescriptor();
                        var idHrzn = charIDToTypeID( "Hrzn" );
                        var idPrc = charIDToTypeID( "#Prc" );
                        desc2623.putUnitDouble( idHrzn, idPrc, 14.814815 );
                        var idVrtc = charIDToTypeID( "Vrtc" );
                        var idPrc = charIDToTypeID( "#Prc" );
                        desc2623.putUnitDouble( idVrtc, idPrc, 52.978903 );
                    var idPnt = charIDToTypeID( "Pnt " );
                    desc2621.putObject( idTxtC, idPnt, desc2623 );
                    var idtextGridding = stringIDToTypeID( "textGridding" );
                    var idtextGridding = stringIDToTypeID( "textGridding" );
                    var idNone = charIDToTypeID( "None" );
                    desc2621.putEnumerated( idtextGridding, idtextGridding, idNone );
                    var idOrnt = charIDToTypeID( "Ornt" );
                    var idOrnt = charIDToTypeID( "Ornt" );
                    var idHrzn = charIDToTypeID( "Hrzn" );
                    desc2621.putEnumerated( idOrnt, idOrnt, idHrzn );
                    var idAntA = charIDToTypeID( "AntA" );
                    var idAnnt = charIDToTypeID( "Annt" );
                    var idantiAliasSharp = stringIDToTypeID( "antiAliasSharp" );
                    desc2621.putEnumerated( idAntA, idAnnt, idantiAliasSharp );
                    var idbounds = stringIDToTypeID( "bounds" );
                        var desc2624 = new ActionDescriptor();
                        var idLeft = charIDToTypeID( "Left" );
                        var idPxl = charIDToTypeID( "#Pxl" );
                        desc2624.putUnitDouble( idLeft, idPxl, 0.000000 );
                        var idTop = charIDToTypeID( "Top " );
                        var idPxl = charIDToTypeID( "#Pxl" );
                        desc2624.putUnitDouble( idTop, idPxl, -26.544998 );
                        var idRght = charIDToTypeID( "Rght" );
                        var idPxl = charIDToTypeID( "#Pxl" );
                        desc2624.putUnitDouble( idRght, idPxl, 257.000000 );
                        var idBtom = charIDToTypeID( "Btom" );
                        var idPxl = charIDToTypeID( "#Pxl" );
                        desc2624.putUnitDouble( idBtom, idPxl, 56.482193 );
                    var idbounds = stringIDToTypeID( "bounds" );
                    desc2621.putObject( idbounds, idbounds, desc2624 );
                    var idboundingBox = stringIDToTypeID( "boundingBox" );
                        var desc2625 = new ActionDescriptor();
                        var idLeft = charIDToTypeID( "Left" );
                        var idPxl = charIDToTypeID( "#Pxl" );
                        desc2625.putUnitDouble( idLeft, idPxl, 52.505478 );
                        var idTop = charIDToTypeID( "Top " );
                        var idPxl = charIDToTypeID( "#Pxl" );
                        desc2625.putUnitDouble( idTop, idPxl, -16.505173 );
                        var idRght = charIDToTypeID( "Rght" );
                        var idPxl = charIDToTypeID( "#Pxl" );
                        desc2625.putUnitDouble( idRght, idPxl, 115.206406 );
                        var idBtom = charIDToTypeID( "Btom" );
                        var idPxl = charIDToTypeID( "#Pxl" );
                        desc2625.putUnitDouble( idBtom, idPxl, 9.764572 );
                    var idboundingBox = stringIDToTypeID( "boundingBox" );
                    desc2621.putObject( idboundingBox, idboundingBox, desc2625 );
                    var idtextShape = stringIDToTypeID( "textShape" );
                        var list297 = new ActionList();
                            var desc2626 = new ActionDescriptor();
                            var idPath = charIDToTypeID( "Path" );
                                var desc2627 = new ActionDescriptor();
                                var idpathComponents = stringIDToTypeID( "pathComponents" );
                                    var list298 = new ActionList();
                                        var desc2628 = new ActionDescriptor();
                                        var idshapeOperation = stringIDToTypeID( "shapeOperation" );
                                        var idshapeOperation = stringIDToTypeID( "shapeOperation" );
                                        var idxor = stringIDToTypeID( "xor" );
                                        desc2628.putEnumerated( idshapeOperation, idshapeOperation, idxor );
                                        var idSbpL = charIDToTypeID( "SbpL" );
                                            var list299 = new ActionList();
                                                var desc2629 = new ActionDescriptor();
                                                var idPts = charIDToTypeID( "Pts " );
                                                    var list300 = new ActionList();
                                                        var desc2630 = new ActionDescriptor();
                                                        var idAnch = charIDToTypeID( "Anch" );
                                                            var desc2631 = new ActionDescriptor();
                                                            var idHrzn = charIDToTypeID( "Hrzn" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2631.putUnitDouble( idHrzn, idPxl, 76.000000 );
                                                            var idVrtc = charIDToTypeID( "Vrtc" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2631.putUnitDouble( idVrtc, idPxl, 288.000000 );
                                                        var idPnt = charIDToTypeID( "Pnt " );
                                                        desc2630.putObject( idAnch, idPnt, desc2631 );
                                                    var idPthp = charIDToTypeID( "Pthp" );
                                                    list300.putObject( idPthp, desc2630 );
                                                        var desc2632 = new ActionDescriptor();
                                                        var idAnch = charIDToTypeID( "Anch" );
                                                            var desc2633 = new ActionDescriptor();
                                                            var idHrzn = charIDToTypeID( "Hrzn" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2633.putUnitDouble( idHrzn, idPxl, 177.000000 );
                                                            var idVrtc = charIDToTypeID( "Vrtc" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2633.putUnitDouble( idVrtc, idPxl, 239.000000 );
                                                        var idPnt = charIDToTypeID( "Pnt " );
                                                        desc2632.putObject( idAnch, idPnt, desc2633 );
                                                        var idFwd = charIDToTypeID( "Fwd " );
                                                            var desc2634 = new ActionDescriptor();
                                                            var idHrzn = charIDToTypeID( "Hrzn" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2634.putUnitDouble( idHrzn, idPxl, 216.000000 );
                                                            var idVrtc = charIDToTypeID( "Vrtc" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2634.putUnitDouble( idVrtc, idPxl, 271.000000 );
                                                        var idPnt = charIDToTypeID( "Pnt " );
                                                        desc2632.putObject( idFwd, idPnt, desc2634 );
                                                        var idBwd = charIDToTypeID( "Bwd " );
                                                            var desc2635 = new ActionDescriptor();
                                                            var idHrzn = charIDToTypeID( "Hrzn" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2635.putUnitDouble( idHrzn, idPxl, 138.000000 );
                                                            var idVrtc = charIDToTypeID( "Vrtc" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2635.putUnitDouble( idVrtc, idPxl, 207.000000 );
                                                        var idPnt = charIDToTypeID( "Pnt " );
                                                        desc2632.putObject( idBwd, idPnt, desc2635 );
                                                        var idSmoo = charIDToTypeID( "Smoo" );
                                                        desc2632.putBoolean( idSmoo, true );
                                                    var idPthp = charIDToTypeID( "Pthp" );
                                                    list300.putObject( idPthp, desc2632 );
                                                        var desc2636 = new ActionDescriptor();
                                                        var idAnch = charIDToTypeID( "Anch" );
                                                            var desc2637 = new ActionDescriptor();
                                                            var idHrzn = charIDToTypeID( "Hrzn" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2637.putUnitDouble( idHrzn, idPxl, 333.000000 );
                                                            var idVrtc = charIDToTypeID( "Vrtc" );
                                                            var idPxl = charIDToTypeID( "#Pxl" );
                                                            desc2637.putUnitDouble( idVrtc, idPxl, 245.000000 );
                                                        var idPnt = charIDToTypeID( "Pnt " );
                                                        desc2636.putObject( idAnch, idPnt, desc2637 );
                                                    var idPthp = charIDToTypeID( "Pthp" );
                                                    list300.putObject( idPthp, desc2636 );
                                                desc2629.putList( idPts, list300 );
                                            var idSbpl = charIDToTypeID( "Sbpl" );
                                            list299.putObject( idSbpl, desc2629 );
                                        desc2628.putList( idSbpL, list299 );
                                    var idPaCm = charIDToTypeID( "PaCm" );
                                    list298.putObject( idPaCm, desc2628 );
                                desc2627.putList( idpathComponents, list298 );
                            var idpathClass = stringIDToTypeID( "pathClass" );
                            desc2626.putObject( idPath, idpathClass, desc2627 );
                            var idtRange = stringIDToTypeID( "tRange" );
                                var desc2638 = new ActionDescriptor();
                                var idStrt = charIDToTypeID( "Strt" );
                                desc2638.putDouble( idStrt, 0.668286 );
                                var idEnd = charIDToTypeID( "End " );
                                desc2638.putDouble( idEnd, 2.000000 );
                            var idRang = charIDToTypeID( "Rang" );
                            desc2626.putObject( idtRange, idRang, desc2638 );
                            var idTEXT = charIDToTypeID( "TEXT" );
                            var idTEXT = charIDToTypeID( "TEXT" );
                            var idonACurve = stringIDToTypeID( "onACurve" );
                            desc2626.putEnumerated( idTEXT, idTEXT, idonACurve );
                            var idOrnt = charIDToTypeID( "Ornt" );
                            var idOrnt = charIDToTypeID( "Ornt" );
                            var idHrzn = charIDToTypeID( "Hrzn" );
                            desc2626.putEnumerated( idOrnt, idOrnt, idHrzn );
                            var idTrnf = charIDToTypeID( "Trnf" );
                                var desc2639 = new ActionDescriptor();
                                var idxx = stringIDToTypeID( "xx" );
                                desc2639.putDouble( idxx, 1.000000 );
                                var idxy = stringIDToTypeID( "xy" );
                                desc2639.putDouble( idxy, 0.000000 );
                                var idyx = stringIDToTypeID( "yx" );
                                desc2639.putDouble( idyx, 0.000000 );
                                var idyy = stringIDToTypeID( "yy" );
                                desc2639.putDouble( idyy, 1.000000 );
                                var idtx = stringIDToTypeID( "tx" );
                                desc2639.putDouble( idtx, -76.000000 );
                                var idty = stringIDToTypeID( "ty" );
                                desc2639.putDouble( idty, -231.517807 );
                            var idTrnf = charIDToTypeID( "Trnf" );
                            desc2626.putObject( idTrnf, idTrnf, desc2639 );
                            var idrowCount = stringIDToTypeID( "rowCount" );
                            desc2626.putInteger( idrowCount, 1 );
                            var idcolumnCount = stringIDToTypeID( "columnCount" );
                            desc2626.putInteger( idcolumnCount, 1 );
                            var idrowMajorOrder = stringIDToTypeID( "rowMajorOrder" );
                            desc2626.putBoolean( idrowMajorOrder, true );
                            var idrowGutter = stringIDToTypeID( "rowGutter" );
                            var idPxl = charIDToTypeID( "#Pxl" );
                            desc2626.putUnitDouble( idrowGutter, idPxl, 0.000000 );
                            var idcolumnGutter = stringIDToTypeID( "columnGutter" );
                            var idPxl = charIDToTypeID( "#Pxl" );
                            desc2626.putUnitDouble( idcolumnGutter, idPxl, 0.000000 );
                            var idSpcn = charIDToTypeID( "Spcn" );
                            var idPxl = charIDToTypeID( "#Pxl" );
                            desc2626.putUnitDouble( idSpcn, idPxl, 0.000000 );
                            var idframeBaselineAlignment = stringIDToTypeID( "frameBaselineAlignment" );
                            var idframeBaselineAlignment = stringIDToTypeID( "frameBaselineAlignment" );
                            var idalignByAscent = stringIDToTypeID( "alignByAscent" );
                            desc2626.putEnumerated( idframeBaselineAlignment, idframeBaselineAlignment, idalignByAscent );
                            var idfirstBaselineMinimum = stringIDToTypeID( "firstBaselineMinimum" );
                            var idPxl = charIDToTypeID( "#Pxl" );
                            desc2626.putUnitDouble( idfirstBaselineMinimum, idPxl, 0.000000 );
                            var idFlip = charIDToTypeID( "Flip" );
                            desc2626.putBoolean( idFlip, false );
                            var idpathTypeEffect = stringIDToTypeID( "pathTypeEffect" );
                            var idpathTypeEffect = stringIDToTypeID( "pathTypeEffect" );
                            var idrainbowEffect = stringIDToTypeID( "rainbowEffect" );
                            desc2626.putEnumerated( idpathTypeEffect, idpathTypeEffect, idrainbowEffect );
                            var idpathTypeAlignment = stringIDToTypeID( "pathTypeAlignment" );
                            var idpathTypeAlignment = stringIDToTypeID( "pathTypeAlignment" );
                            var idbaselineAlignment = stringIDToTypeID( "baselineAlignment" );
                            desc2626.putEnumerated( idpathTypeAlignment, idpathTypeAlignment, idbaselineAlignment );
                            var idpathTypeAlignTo = stringIDToTypeID( "pathTypeAlignTo" );
                            var idpathTypeAlignTo = stringIDToTypeID( "pathTypeAlignTo" );
                            var idtoPathTop = stringIDToTypeID( "toPathTop" );
                            desc2626.putEnumerated( idpathTypeAlignTo, idpathTypeAlignTo, idtoPathTop );
                            var idpathTypeSpacing = stringIDToTypeID( "pathTypeSpacing" );
                            desc2626.putInteger( idpathTypeSpacing, 0 );
                        var idtextShape = stringIDToTypeID( "textShape" );
                        list297.putObject( idtextShape, desc2626 );
                    desc2621.putList( idtextShape, list297 );
                    var idTxtt = charIDToTypeID( "Txtt" );
                        var list301 = new ActionList();
                            var desc2640 = new ActionDescriptor();
                            var idFrom = charIDToTypeID( "From" );
                            desc2640.putInteger( idFrom, 0 );
                            var idT = charIDToTypeID( "T   " );
                            desc2640.putInteger( idT, 5 );
                            var idTxtS = charIDToTypeID( "TxtS" );
                                var desc2641 = new ActionDescriptor();
                                var idstyleSheetHasParent = stringIDToTypeID( "styleSheetHasParent" );
                                desc2641.putBoolean( idstyleSheetHasParent, true );
                                var idfontPostScriptName = stringIDToTypeID( "fontPostScriptName" );
                                desc2641.putString( idfontPostScriptName, """Lato-Regular""" );
                                var idFntN = charIDToTypeID( "FntN" );
                                desc2641.putString( idFntN, """Lato""" );
                                var idFntS = charIDToTypeID( "FntS" );
                                desc2641.putString( idFntS, """Regular""" );
                                var idScrp = charIDToTypeID( "Scrp" );
                                desc2641.putInteger( idScrp, 0 );
                                var idFntT = charIDToTypeID( "FntT" );
                                desc2641.putInteger( idFntT, 1 );
                                var idfontAvailable = stringIDToTypeID( "fontAvailable" );
                                desc2641.putBoolean( idfontAvailable, true );
                                var idSz = charIDToTypeID( "Sz  " );
                                var idPxl = charIDToTypeID( "#Pxl" );
                                desc2641.putUnitDouble( idSz, idPxl, 31.000000 );
                                var idimpliedFontSize = stringIDToTypeID( "impliedFontSize" );
                                var idPxl = charIDToTypeID( "#Pxl" );
                                desc2641.putUnitDouble( idimpliedFontSize, idPxl, 31.000000 );
                                var idautoLeading = stringIDToTypeID( "autoLeading" );
                                desc2641.putBoolean( idautoLeading, false );
                                var idLdng = charIDToTypeID( "Ldng" );
                                var idPxl = charIDToTypeID( "#Pxl" );
                                desc2641.putUnitDouble( idLdng, idPxl, 25.000000 );
                                var idimpliedLeading = stringIDToTypeID( "impliedLeading" );
                                var idPxl = charIDToTypeID( "#Pxl" );
                                desc2641.putUnitDouble( idimpliedLeading, idPxl, 25.000000 );
                                var iddigitSet = stringIDToTypeID( "digitSet" );
                                var iddigitSet = stringIDToTypeID( "digitSet" );
                                var iddefaultDigits = stringIDToTypeID( "defaultDigits" );
                                desc2641.putEnumerated( iddigitSet, iddigitSet, iddefaultDigits );
                                var idmarkYDistFromBaseline = stringIDToTypeID( "markYDistFromBaseline" );
                                var idPxl = charIDToTypeID( "#Pxl" );
                                desc2641.putUnitDouble( idmarkYDistFromBaseline, idPxl, 100.000000 );
                                var idtextLanguage = stringIDToTypeID( "textLanguage" );
                                var idtextLanguage = stringIDToTypeID( "textLanguage" );
                                var idenglishLanguage = stringIDToTypeID( "englishLanguage" );
                                desc2641.putEnumerated( idtextLanguage, idtextLanguage, idenglishLanguage );
                                var idbaseParentStyle = stringIDToTypeID( "baseParentStyle" );
                                    var desc2642 = new ActionDescriptor();
                                    var idfontPostScriptName = stringIDToTypeID( "fontPostScriptName" );
                                    desc2642.putString( idfontPostScriptName, """MyriadPro-Regular""" );
                                    var idFntN = charIDToTypeID( "FntN" );
                                    desc2642.putString( idFntN, """Myriad Pro""" );
                                    var idFntS = charIDToTypeID( "FntS" );
                                    desc2642.putString( idFntS, """Regular""" );
                                    var idScrp = charIDToTypeID( "Scrp" );
                                    desc2642.putInteger( idScrp, 0 );
                                    var idFntT = charIDToTypeID( "FntT" );
                                    desc2642.putInteger( idFntT, 0 );
                                    var idfontAvailable = stringIDToTypeID( "fontAvailable" );
                                    desc2642.putBoolean( idfontAvailable, true );
                                    var idSz = charIDToTypeID( "Sz  " );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( idSz, idPxl, 12.000000 );
                                    var idimpliedFontSize = stringIDToTypeID( "impliedFontSize" );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( idimpliedFontSize, idPxl, 12.000000 );
                                    var idHrzS = charIDToTypeID( "HrzS" );
                                    desc2642.putDouble( idHrzS, 100.000000 );
                                    var idVrtS = charIDToTypeID( "VrtS" );
                                    desc2642.putDouble( idVrtS, 100.000000 );
                                    var idsyntheticBold = stringIDToTypeID( "syntheticBold" );
                                    desc2642.putBoolean( idsyntheticBold, false );
                                    var idsyntheticItalic = stringIDToTypeID( "syntheticItalic" );
                                    desc2642.putBoolean( idsyntheticItalic, false );
                                    var idautoLeading = stringIDToTypeID( "autoLeading" );
                                    desc2642.putBoolean( idautoLeading, true );
                                    var idTrck = charIDToTypeID( "Trck" );
                                    desc2642.putInteger( idTrck, 0 );
                                    var idBsln = charIDToTypeID( "Bsln" );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( idBsln, idPxl, 0.000000 );
                                    var idimpliedBaselineShift = stringIDToTypeID( "impliedBaselineShift" );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( idimpliedBaselineShift, idPxl, 0.000000 );
                                    var idcharacterRotation = stringIDToTypeID( "characterRotation" );
                                    desc2642.putDouble( idcharacterRotation, 0.000000 );
                                    var idAtKr = charIDToTypeID( "AtKr" );
                                    var idAtKr = charIDToTypeID( "AtKr" );
                                    var idmetricsKern = stringIDToTypeID( "metricsKern" );
                                    desc2642.putEnumerated( idAtKr, idAtKr, idmetricsKern );
                                    var idfontCaps = stringIDToTypeID( "fontCaps" );
                                    var idfontCaps = stringIDToTypeID( "fontCaps" );
                                    var idNrml = charIDToTypeID( "Nrml" );
                                    desc2642.putEnumerated( idfontCaps, idfontCaps, idNrml );
                                    var iddigitSet = stringIDToTypeID( "digitSet" );
                                    var iddigitSet = stringIDToTypeID( "digitSet" );
                                    var iddefaultDigits = stringIDToTypeID( "defaultDigits" );
                                    desc2642.putEnumerated( iddigitSet, iddigitSet, iddefaultDigits );
                                    var iddirOverride = stringIDToTypeID( "dirOverride" );
                                    var iddirOverride = stringIDToTypeID( "dirOverride" );
                                    var iddirOverrideDefault = stringIDToTypeID( "dirOverrideDefault" );
                                    desc2642.putEnumerated( iddirOverride, iddirOverride, iddirOverrideDefault );
                                    var idkashidas = stringIDToTypeID( "kashidas" );
                                    var idkashidas = stringIDToTypeID( "kashidas" );
                                    var idkashidaDefault = stringIDToTypeID( "kashidaDefault" );
                                    desc2642.putEnumerated( idkashidas, idkashidas, idkashidaDefault );
                                    var iddiacVPos = stringIDToTypeID( "diacVPos" );
                                    var iddiacVPos = stringIDToTypeID( "diacVPos" );
                                    var iddiacVPosOpenType = stringIDToTypeID( "diacVPosOpenType" );
                                    desc2642.putEnumerated( iddiacVPos, iddiacVPos, iddiacVPosOpenType );
                                    var iddiacXOffset = stringIDToTypeID( "diacXOffset" );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( iddiacXOffset, idPxl, 0.000000 );
                                    var iddiacYOffset = stringIDToTypeID( "diacYOffset" );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( iddiacYOffset, idPxl, 0.000000 );
                                    var idmarkYDistFromBaseline = stringIDToTypeID( "markYDistFromBaseline" );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( idmarkYDistFromBaseline, idPxl, 100.000000 );
                                    var idbaseline = stringIDToTypeID( "baseline" );
                                    var idbaseline = stringIDToTypeID( "baseline" );
                                    var idNrml = charIDToTypeID( "Nrml" );
                                    desc2642.putEnumerated( idbaseline, idbaseline, idNrml );
                                    var idotbaseline = stringIDToTypeID( "otbaseline" );
                                    var idotbaseline = stringIDToTypeID( "otbaseline" );
                                    var idNrml = charIDToTypeID( "Nrml" );
                                    desc2642.putEnumerated( idotbaseline, idotbaseline, idNrml );
                                    var idstrikethrough = stringIDToTypeID( "strikethrough" );
                                    var idstrikethrough = stringIDToTypeID( "strikethrough" );
                                    var idstrikethroughOff = stringIDToTypeID( "strikethroughOff" );
                                    desc2642.putEnumerated( idstrikethrough, idstrikethrough, idstrikethroughOff );
                                    var idUndl = charIDToTypeID( "Undl" );
                                    var idUndl = charIDToTypeID( "Undl" );
                                    var idunderlineOff = stringIDToTypeID( "underlineOff" );
                                    desc2642.putEnumerated( idUndl, idUndl, idunderlineOff );
                                    var idunderlineOffset = stringIDToTypeID( "underlineOffset" );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( idunderlineOffset, idPxl, 0.000000 );
                                    var idligature = stringIDToTypeID( "ligature" );
                                    desc2642.putBoolean( idligature, true );
                                    var idaltligature = stringIDToTypeID( "altligature" );
                                    desc2642.putBoolean( idaltligature, false );
                                    var idcontextualLigatures = stringIDToTypeID( "contextualLigatures" );
                                    desc2642.putBoolean( idcontextualLigatures, false );
                                    var idalternateLigatures = stringIDToTypeID( "alternateLigatures" );
                                    desc2642.putBoolean( idalternateLigatures, false );
                                    var idoldStyle = stringIDToTypeID( "oldStyle" );
                                    desc2642.putBoolean( idoldStyle, false );
                                    var idfractions = stringIDToTypeID( "fractions" );
                                    desc2642.putBoolean( idfractions, false );
                                    var idordinals = stringIDToTypeID( "ordinals" );
                                    desc2642.putBoolean( idordinals, false );
                                    var idswash = stringIDToTypeID( "swash" );
                                    desc2642.putBoolean( idswash, false );
                                    var idtitling = stringIDToTypeID( "titling" );
                                    desc2642.putBoolean( idtitling, false );
                                    var idconnectionForms = stringIDToTypeID( "connectionForms" );
                                    desc2642.putBoolean( idconnectionForms, false );
                                    var idstylisticAlternates = stringIDToTypeID( "stylisticAlternates" );
                                    desc2642.putBoolean( idstylisticAlternates, false );
                                    var idornaments = stringIDToTypeID( "ornaments" );
                                    desc2642.putBoolean( idornaments, false );
                                    var idjustificationAlternates = stringIDToTypeID( "justificationAlternates" );
                                    desc2642.putBoolean( idjustificationAlternates, false );
                                    var idfigureStyle = stringIDToTypeID( "figureStyle" );
                                    var idfigureStyle = stringIDToTypeID( "figureStyle" );
                                    var idNrml = charIDToTypeID( "Nrml" );
                                    desc2642.putEnumerated( idfigureStyle, idfigureStyle, idNrml );
                                    var idproportionalMetrics = stringIDToTypeID( "proportionalMetrics" );
                                    desc2642.putBoolean( idproportionalMetrics, false );
                                    var idkana = stringIDToTypeID( "kana" );
                                    desc2642.putBoolean( idkana, false );
                                    var iditalics = stringIDToTypeID( "italics" );
                                    desc2642.putBoolean( iditalics, false );
                                    var idruby = stringIDToTypeID( "ruby" );
                                    desc2642.putBoolean( idruby, false );
                                    var idbaselineDirection = stringIDToTypeID( "baselineDirection" );
                                    var idbaselineDirection = stringIDToTypeID( "baselineDirection" );
                                    var idrotated = stringIDToTypeID( "rotated" );
                                    desc2642.putEnumerated( idbaselineDirection, idbaselineDirection, idrotated );
                                    var idtextLanguage = stringIDToTypeID( "textLanguage" );
                                    var idtextLanguage = stringIDToTypeID( "textLanguage" );
                                    var idenglishLanguage = stringIDToTypeID( "englishLanguage" );
                                    desc2642.putEnumerated( idtextLanguage, idtextLanguage, idenglishLanguage );
                                    var idjapaneseAlternate = stringIDToTypeID( "japaneseAlternate" );
                                    var idjapaneseAlternate = stringIDToTypeID( "japaneseAlternate" );
                                    var iddefaultForm = stringIDToTypeID( "defaultForm" );
                                    desc2642.putEnumerated( idjapaneseAlternate, idjapaneseAlternate, iddefaultForm );
                                    var idmojiZume = stringIDToTypeID( "mojiZume" );
                                    desc2642.putDouble( idmojiZume, 0.000000 );
                                    var idgridAlignment = stringIDToTypeID( "gridAlignment" );
                                    var idgridAlignment = stringIDToTypeID( "gridAlignment" );
                                    var idroman = stringIDToTypeID( "roman" );
                                    desc2642.putEnumerated( idgridAlignment, idgridAlignment, idroman );
                                    var idenableWariChu = stringIDToTypeID( "enableWariChu" );
                                    desc2642.putBoolean( idenableWariChu, false );
                                    var idwariChuCount = stringIDToTypeID( "wariChuCount" );
                                    desc2642.putInteger( idwariChuCount, 2 );
                                    var idwariChuLineGap = stringIDToTypeID( "wariChuLineGap" );
                                    desc2642.putInteger( idwariChuLineGap, 0 );
                                    var idwariChuScale = stringIDToTypeID( "wariChuScale" );
                                    desc2642.putDouble( idwariChuScale, 0.500000 );
                                    var idwariChuWidow = stringIDToTypeID( "wariChuWidow" );
                                    desc2642.putInteger( idwariChuWidow, 2 );
                                    var idwariChuOrphan = stringIDToTypeID( "wariChuOrphan" );
                                    desc2642.putInteger( idwariChuOrphan, 2 );
                                    var idwariChuJustification = stringIDToTypeID( "wariChuJustification" );
                                    var idwariChuJustification = stringIDToTypeID( "wariChuJustification" );
                                    var idwariChuAutoJustify = stringIDToTypeID( "wariChuAutoJustify" );
                                    desc2642.putEnumerated( idwariChuJustification, idwariChuJustification, idwariChuAutoJustify );
                                    var idtcyUpDown = stringIDToTypeID( "tcyUpDown" );
                                    desc2642.putInteger( idtcyUpDown, 0 );
                                    var idtcyLeftRight = stringIDToTypeID( "tcyLeftRight" );
                                    desc2642.putInteger( idtcyLeftRight, 0 );
                                    var idleftAki = stringIDToTypeID( "leftAki" );
                                    desc2642.putDouble( idleftAki, -1.000000 );
                                    var idrightAki = stringIDToTypeID( "rightAki" );
                                    desc2642.putDouble( idrightAki, -1.000000 );
                                    var idjiDori = stringIDToTypeID( "jiDori" );
                                    desc2642.putInteger( idjiDori, 0 );
                                    var idnoBreak = stringIDToTypeID( "noBreak" );
                                    desc2642.putBoolean( idnoBreak, false );
                                    var idClr = charIDToTypeID( "Clr " );
                                        var desc2643 = new ActionDescriptor();
                                        var idRd = charIDToTypeID( "Rd  " );
                                        desc2643.putDouble( idRd, 0.000000 );
                                        var idGrn = charIDToTypeID( "Grn " );
                                        desc2643.putDouble( idGrn, 0.000000 );
                                        var idBl = charIDToTypeID( "Bl  " );
                                        desc2643.putDouble( idBl, 0.000000 );
                                    var idRGBC = charIDToTypeID( "RGBC" );
                                    desc2642.putObject( idClr, idRGBC, desc2643 );
                                    var idstrokeColor = stringIDToTypeID( "strokeColor" );
                                        var desc2644 = new ActionDescriptor();
                                        var idRd = charIDToTypeID( "Rd  " );
                                        desc2644.putDouble( idRd, 0.000000 );
                                        var idGrn = charIDToTypeID( "Grn " );
                                        desc2644.putDouble( idGrn, 0.000000 );
                                        var idBl = charIDToTypeID( "Bl  " );
                                        desc2644.putDouble( idBl, 0.000000 );
                                    var idRGBC = charIDToTypeID( "RGBC" );
                                    desc2642.putObject( idstrokeColor, idRGBC, desc2644 );
                                    var idFl = charIDToTypeID( "Fl  " );
                                    desc2642.putBoolean( idFl, true );
                                    var idStrk = charIDToTypeID( "Strk" );
                                    desc2642.putBoolean( idStrk, false );
                                    var idfillFirst = stringIDToTypeID( "fillFirst" );
                                    desc2642.putBoolean( idfillFirst, true );
                                    var idfillOverPrint = stringIDToTypeID( "fillOverPrint" );
                                    desc2642.putBoolean( idfillOverPrint, false );
                                    var idstrokeOverPrint = stringIDToTypeID( "strokeOverPrint" );
                                    desc2642.putBoolean( idstrokeOverPrint, false );
                                    var idlineCap = stringIDToTypeID( "lineCap" );
                                    var idlineCap = stringIDToTypeID( "lineCap" );
                                    var idbuttCap = stringIDToTypeID( "buttCap" );
                                    desc2642.putEnumerated( idlineCap, idlineCap, idbuttCap );
                                    var idlineJoin = stringIDToTypeID( "lineJoin" );
                                    var idlineJoin = stringIDToTypeID( "lineJoin" );
                                    var idmiterJoin = stringIDToTypeID( "miterJoin" );
                                    desc2642.putEnumerated( idlineJoin, idlineJoin, idmiterJoin );
                                    var idlineWidth = stringIDToTypeID( "lineWidth" );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( idlineWidth, idPxl, 1.000000 );
                                    var idmiterLimit = stringIDToTypeID( "miterLimit" );
                                    var idPxl = charIDToTypeID( "#Pxl" );
                                    desc2642.putUnitDouble( idmiterLimit, idPxl, 4.000000 );
                                    var idlineDashoffset = stringIDToTypeID( "lineDashoffset" );
                                    desc2642.putDouble( idlineDashoffset, 0.000000 );
                                var idTxtS = charIDToTypeID( "TxtS" );
                                desc2641.putObject( idbaseParentStyle, idTxtS, desc2642 );
                            var idTxtS = charIDToTypeID( "TxtS" );
                            desc2640.putObject( idTxtS, idTxtS, desc2641 );
                        var idTxtt = charIDToTypeID( "Txtt" );
                        list301.putObject( idTxtt, desc2640 );
                    desc2621.putList( idTxtt, list301 );
                    var idparagraphStyleRange = stringIDToTypeID( "paragraphStyleRange" );
                        var list302 = new ActionList();
                            var desc2645 = new ActionDescriptor();
                            var idFrom = charIDToTypeID( "From" );
                            desc2645.putInteger( idFrom, 0 );
                            var idT = charIDToTypeID( "T   " );
                            desc2645.putInteger( idT, 5 );
                            var idparagraphStyle = stringIDToTypeID( "paragraphStyle" );
                                var desc2646 = new ActionDescriptor();
                                var idstyleSheetHasParent = stringIDToTypeID( "styleSheetHasParent" );
                                desc2646.putBoolean( idstyleSheetHasParent, true );
                                var iddirectionType = stringIDToTypeID( "directionType" );
                                var iddirectionType = stringIDToTypeID( "directionType" );
                                var iddirLeftToRight = stringIDToTypeID( "dirLeftToRight" );
                                desc2646.putEnumerated( iddirectionType, iddirectionType, iddirLeftToRight );
                                var idhyphenate = stringIDToTypeID( "hyphenate" );
                                desc2646.putBoolean( idhyphenate, true );
                                var idhyphenateWordSize = stringIDToTypeID( "hyphenateWordSize" );
                                desc2646.putInteger( idhyphenateWordSize, 8 );
                                var idhyphenatePreLength = stringIDToTypeID( "hyphenatePreLength" );
                                desc2646.putInteger( idhyphenatePreLength, 3 );
                                var idhyphenatePostLength = stringIDToTypeID( "hyphenatePostLength" );
                                desc2646.putInteger( idhyphenatePostLength, 3 );
                                var idhyphenateLimit = stringIDToTypeID( "hyphenateLimit" );
                                desc2646.putInteger( idhyphenateLimit, 2 );
                                var idhyphenationZone = stringIDToTypeID( "hyphenationZone" );
                                desc2646.putDouble( idhyphenationZone, 36.000000 );
                                var idhyphenateCapitalized = stringIDToTypeID( "hyphenateCapitalized" );
                                desc2646.putBoolean( idhyphenateCapitalized, true );
                                var idburasagari = stringIDToTypeID( "burasagari" );
                                var idburasagari = stringIDToTypeID( "burasagari" );
                                var idburasagariStandard = stringIDToTypeID( "burasagariStandard" );
                                desc2646.putEnumerated( idburasagari, idburasagari, idburasagariStandard );
                                var idtextEveryLineComposer = stringIDToTypeID( "textEveryLineComposer" );
                                desc2646.putBoolean( idtextEveryLineComposer, true );
                            var idparagraphStyle = stringIDToTypeID( "paragraphStyle" );
                            desc2645.putObject( idparagraphStyle, idparagraphStyle, desc2646 );
                        var idparagraphStyleRange = stringIDToTypeID( "paragraphStyleRange" );
                        list302.putObject( idparagraphStyleRange, desc2645 );
                    desc2621.putList( idparagraphStyleRange, list302 );
                    var idkerningRange = stringIDToTypeID( "kerningRange" );
                        var list303 = new ActionList();
                    desc2621.putList( idkerningRange, list303 );
                var idTxLr = charIDToTypeID( "TxLr" );
                desc2620.putObject( idUsng, idTxLr, desc2621 );
                var idLyrI = charIDToTypeID( "LyrI" );
                desc2620.putInteger( idLyrI, 65 );
            executeAction( idMk, desc2620, DialogModes.NO );
            
            • 3. Re: Insert text in freeform path
              hardestfred Level 1

              Oh boy, what mess did I get myself into.

               

              Thanks for the help, Jarda.

              I was afraid it would require to use the evil ScriptListener, but considering your answer, I guess there's no way to do it the "simple javascript way", eh ?

               

              Hmm... maybe it simpler than it looks.

               

              From what I gathered, it boils down to mixing a list of pathpoints (in short, a "textShape") onto a text layer.

              Based on this, it may be possible to get the anchors of a freeform path, create a text layer, create the textShape properties using the anchors and somehow apply it to the text layer.

               

              If anyone has a better idea, please do tell.

              • 4. Re: Insert text in freeform path
                Jarda Bereza Level 4

                Final code could have something about 10-30 lines.

                It's easy if you know exactly what you do.

                 

                Here I did some work with text: Magic scripts for Photoshop

                Columns and align to baseline.  It uses similar method. But I am putting another descriptor inside.

                • 5. Re: Insert text in freeform path
                  hardestfred Level 1

                  At first I was like "Whaaat? The guy gives me compiled code, what am I supposed to do with it?"...

                  Turns out I had opened the only script that's compiled to jsxbin (Advanced Font Remap)

                  I reckon the others will prove to be most instructive. Thanks, mate ! I'll dig into them.

                   

                  Do you think I'm on the right track with my idea, or am I going to run into a dead end ?