3 Replies Latest reply on Dec 11, 2012 9:05 AM by lithodora

    Creating Styles.. and then nesting styles

    lithodora Level 1

      Seems simple enough:

       

      tell application "Adobe InDesign CS5.5"

      tell active document

        set myCharacterStyle to make character style with properties {name:"Year", size:26.0, fill color:"Paper", stroke color:"Black", stroke weight:0.75, font:"Helvetica", font style:"Black"}

       

        set myCharacterStyle to make character style with properties {name:"Years", size:18.0, fill color:"Black", stroke color:nothing, stroke weight:nothing, horizontal scale:80.0, vertical scale:80.0, font:"Helvetica", font style:"Black"}

       

        set myParagraphStyle to make paragraph style with properties {name:"Year"}

        set nested styles of myParagraphStyle to {{applied character style:"Year", repetition:1, inclusive:false, delimiter:any word}, {applied character style:"Years", repetition:2, inclusive:true, delimiter:any word}}

       

      end tell

      end tell

       

       

      The font and the point size do not come through when the style is created. The nested styles also do not come through.

       

      I tried applied font:"Helvetica" to get 'font family not available'. Also, font:font "Helvetica"...

       

      What I get right now I is no font defined or size. The rest works.

       

      So what am I doing wrong here?


        • 1. Re: Creating Styles.. and then nesting styles
          Mary Posner Level 3

          Try this:

           

          applied font: "Helvetica     Black"

           

          Note that there's a tab between the font name and the font style. 

          1 person found this helpful
          • 2. Re: Creating Styles.. and then nesting styles
            -hans- Level 4

            Hi lithodora,

             

            as Mary Posner wrote a character style doesn't have the property 'font', but 'applied font' and 'font style'.

            "... specified as either a font object or the name of font family."

            just look it up in the dictionary ...

             

            Try always to work with references.

             

             

             

            tell application "Adobe InDesign CS5.5"

                --you've got to set myHelvetica to your needs!

                set myHelveticas to (font family of every font whose name contains "Helvetica") --will return the helvetica font familiy names

                set myHelvetica to item 1 of myHelveticas --just randomly pick one for my example, hoping it's got a 'black' style ;-) ...

               

                tell active document

                    set myCharacterStyle01 to make character style with properties {name:"test", size:26.0, fill color:"Paper", stroke color:"Black", stroke weight:0.75, applied font:myHelvetica, font style:"Black"}

                    set myCharacterStyle02 to make character style with properties {name:"tests", size:18.0, fill color:"Black", stroke color:nothing, stroke weight:nothing, horizontal scale:80.0, vertical scale:80.0, applied font:myHelvetica, font style:"Black"}

                   

                    set myParagraphStyle to make paragraph style with properties {name:"nextTest"}

                   

                    tell myParagraphStyle

                        make new nested style with properties {applied character style:myCharacterStyle01, repetition:1, inclusive:false, delimiter:any word}

                        make new nested style with properties {applied character style:myCharacterStyle02, repetition:2, inclusive:true, delimiter:any word}

                    end tell

                   

                end tell

               

            end tell


            • 3. Re: Creating Styles.. and then nesting styles
              lithodora Level 1

              Thank you for the help!

               

              I had tried the applied font first, but had changed my approach due to the properties returned of the existing style. It didn't have a property for applied font, but did have font. That is why I had gone that way.

               

              Rather than use a repeat to step through every Helvetica till I come up with one that works I have followed what Mary posted which works. I can't believe I forgot to use the Tab.

               

              Again, thank you both for the help.