7 Replies Latest reply on Sep 27, 2016 9:07 AM by tpk1982

    Help Changing Fonts.

    cbishop01 Level 2

      I'm using the below code.  I'm trying to replace a few fonts that are in Paragraph and Character styles. 

       

        function cb7CallBack(target) {
         var docs = app.documents;      
            for (var d = docs.length-1; d >= 0; d--) {      
         var doc=docs[d];     
         var BOLD = doc.characterStyles;      
            for (var a = 0; a < BOLD.length; a++) {      
         if (BOLD[a].appliedFont=="Helvetica Neue LT Pro" && BOLD[a].fontStyle =="77 Bold Condensed") {    
           BOLD[a].appliedFont = "Suisse Int'l Condensed"  
           BOLD[a].fontStyle = "Bold"          
        }
       } 
      }
           for (var d = docs.length-1; d >= 0; d--) {      
         var doc=docs[d];     
         var REG = doc.characterStyles;      
           for (var a = 0; a < REG.length; a++) {      
         if (REG[a].appliedFont=="Helvetica Neue LT Pro" && REG[a].fontStyle =="57 Condensed") {    
           REG[a].appliedFont = "Suisse Int'l Condensed"  
           REG[a].fontStyle = "Regular"          
        }
       }  
      }
      
        • 1. Re: Help Changing Fonts.
          Skemicle Level 3

          Font styles such as bold italic reguler, etc are classified as part of the font name: so to set a font you would use "Arial\tBold" to get the Bold style of Arial. and for the size of the text you would use pointSize rather than fontStyle.. so to make a selection have a size of 32 you would use: app.activeDocument.selection[0].pointSize = "32pt"

          • 2. Re: Help Changing Fonts.
            cbishop01 Level 2

            I should clarify.  The First part of the code works.  "BOLD"  I cannot get the second part to work.

            • 3. Re: Help Changing Fonts.
              tpk1982 Level 4

              Hope it works, also no need use document length twice..try this

               

              function cb7CallBack() {  
                 var docs = app.documents;        
                        for (var d = docs.length-1; d >= 0; d--) {        
                     var doc=docs[d];       
                     var BOLD = doc.characterStyles;        
                                    for (var a = BOLD.length-1; a >= 0; a--) {        
                                            if (BOLD[a].appliedFont=="Helvetica Neue LT Pro" && BOLD[a].fontStyle =="77 Bold Condensed") {       
                                              BOLD[a].appliedFont = "Suisse Int'l Condensed"     
                                              BOLD[a].fontStyle = "Bold"             
                                            }   
                           
                                            if (BOLD[a].appliedFont=="Helvetica Neue LT Pro" && BOLD[a].fontStyle =="57 Condensed") {       
                                              BOLD[a].appliedFont = "Suisse Int'l Condensed"     
                                              BOLD[a].fontStyle = "Regular"             
                                              }     
              
              
                                  }  
                          }        
               }
              
              
              cb7CallBack()
              
              • 4. Re: Help Changing Fonts.
                Peter Kahrel Adobe Community Professional & MVP

                Are you sure that Suisse Int'l Condensed has a Regular font? Somehow Condensed and Regular seem to contradict each other.

                • 5. Re: Help Changing Fonts.
                  cbishop01 Level 2

                  Yes.  There is a Suisse int'l Reg and Suisse int'l Condensed Regular. 

                  • 6. Re: Help Changing Fonts.
                    cbishop01 Level 2

                    UnFortunately No.  It will only changes the 77 Bold COND.  and leaves 57 Cond alone.  I'm guessing because the 57 is in a paragraphStyle.  I've changed characterStyles to paragraphStyle just to see if it would work and it still doesnt.

                    • 7. Re: Help Changing Fonts.
                      tpk1982 Level 4

                      The provided coding only for character style