• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help Changing Fonts.

Advocate ,
Sep 26, 2016 Sep 26, 2016

Copy link to clipboard

Copied

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;    

   var BOLD = doc.characterStyles;     

      for (var a = 0; a < BOLD.length; a++) {     

   if (BOLD.appliedFont=="Helvetica Neue LT Pro" && BOLD.fontStyle =="77 Bold Condensed") {   

     BOLD.appliedFont = "Suisse Int'l Condensed" 

     BOLD.fontStyle = "Bold"         

  }

}

}

     for (var d = docs.length-1; d >= 0; d--) {     

   var doc=docs;    

   var REG = doc.characterStyles;     

     for (var a = 0; a < REG.length; a++) {     

   if (REG.appliedFont=="Helvetica Neue LT Pro" && REG.fontStyle =="57 Condensed") {   

     REG.appliedFont = "Suisse Int'l Condensed" 

     REG.fontStyle = "Regular"         

  }

}

TOPICS
Scripting

Views

408

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 26, 2016 Sep 26, 2016

Copy link to clipboard

Copied

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"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 26, 2016 Sep 26, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 26, 2016 Sep 26, 2016

Copy link to clipboard

Copied

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;      

       var BOLD = doc.characterStyles;       

                      for (var a = BOLD.length-1; a >= 0; a--) {       

                              if (BOLD.appliedFont=="Helvetica Neue LT Pro" && BOLD.fontStyle =="77 Bold Condensed") {      

                                BOLD.appliedFont = "Suisse Int'l Condensed"    

                                BOLD.fontStyle = "Bold"            

                              }  

            

                              if (BOLD.appliedFont=="Helvetica Neue LT Pro" && BOLD.fontStyle =="57 Condensed") {      

                                BOLD.appliedFont = "Suisse Int'l Condensed"    

                                BOLD.fontStyle = "Regular"            

                                }    

                    } 

            }       

}

cb7CallBack()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 27, 2016 Sep 27, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 27, 2016 Sep 27, 2016

Copy link to clipboard

Copied

LATEST

The provided coding only for character style

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2016 Sep 27, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 27, 2016 Sep 27, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines