Skip to main content
Legend
April 2, 2014
Answered

[AS] replace fonts by script or change default font of "Replace font"-dialog (Minion)

  • April 2, 2014
  • 1 reply
  • 1652 views

Hello again,

we are in the process of switching our ci-font to Myriad. Lots of documents will be changed in future, not by batch, but time after time by hand.

I want to enhance my workflow a bit, keeping the steps towards this small.

My 2 ideas are this:

I need a AS-script, which changes our previous fonts Futura and Frutiger to the new upon execution. I would guess, there allready is a script for this. I would need that in AppleScript, to make our adjustments. I should be able to expand the list for the different styles of one font.

Futura ND Book » Myriad Pro Regular

Futura ND demibold » Myriad Pro Semibold

Fritiger Next Pro Light Condesed » Myriad Pro Light Condesed

If I understand the syntax of the script, i would add every font-style and the replacement.

My second idea:

To keep steps few, is there a way to ged rid of the default-font Minion in the "Replace font"-menu, that I only have to do the different styles but InD by default has Myriad in there?

Any suggestions would be great!

This topic has been closed for replies.
Correct answer DBLjan

Well, thank you for your answer, this was helpful and I tried to make it work for me, but I couldnt…then I stumbled upon an other thread, and worked it around to this:

tell application "Adobe InDesign CS5.5"

  activate

          if not (exists active document) then

                    display dialog "Kein Dokument geöffnet." buttons {"Hmpf."} default button 1 with icon 2

          else

                    set user interaction level of script preferences to never interact

  -- Suchabfragen speichern

                    set oldFTP to properties of find text preferences

                    set oldCTP to properties of change text preferences

 

  -- Wechsel

                    set find text preferences to nothing

                    set change text preferences to nothing

 

                    set properties of find text preferences to {applied font:"Futura ND", font style:"Bold"}

                    set properties of change text preferences to {applied font:"JaneAusten", font style:"NoSecret"}

  change text

 

  -- Suchabfragen wiederherstellen

                    set properties of find text preferences to oldFTP

                    set properties of change text preferences to oldCTP

 

                    set user interaction level of script preferences to interact with all

          end if

end tell

Now I can add a whole bunch of converts for every font style. JaneAusten was a obvoius test, but it works.

1 reply

Legend
April 3, 2014

Hi,

I wrote this script there a few years, I hope this can help you


set myMissingDocFonts to {}

set myInddFonts to {}

set myOldTID to text item delimiters

set text item delimiters to tab

tell application "Adobe InDesign CS5"

    activate

    tell document 1

        try

            set myMissingDocFonts to get name of fonts whose status ≠ installed

        end try

        set myLen to length of myMissingDocFonts

    end tell

   

    set myInddFonts to get name of fonts

   

    if myLen = 0 then

        set myFonts to myInddFonts

    else if myLen = 1 then

        set myFonts to {":::Police absente:::"} & myMissingDocFonts & {":::Polices disponibles:::"} & myInddFonts

    else

        set myFonts to {":::Polices absentes:::"} & myMissingDocFonts & {":::Polices disponibles:::"} & myInddFonts

    end if

   

    try

        set myDialog to make dialog with properties {name:":::Polices dans les feuilles de styles de " & name of document 1 & ":::"}

    on error

        display dialog "Veuillez ouvrir un document." with icon 2

        return 0

    end try

   

    tell myDialog

        tell (make dialog column)

            tell (make border panel)

                tell (make dialog column)

                    tell (make dialog row)

                        tell (make dialog column)

                            make static text with properties {static label:"Rechercher:", min width:100}

                            make static text with properties {static label:"Remplacer par:", min width:100}

                        end tell

                        tell (make dialog column)

                            set SearchFontDialog to make dropdown with properties {string list:myFonts, selected index:0}

                            set ReplaceFontDialog to make dropdown with properties {string list:myInddFonts, selected index:0}

                        end tell

                    end tell

                    tell (make dialog row)

                        tell (make dialog column)

                            make static text with properties {static label:"", min width:100}

                            make static text with properties {static label:"", min width:100}

                        end tell

                        tell (make dialog column)

                            set ParagraphStyleDialog to make checkbox control with properties {static label:"Styles de paragraphes", checked state:true, min width:45}

                            set CharacterStyleDialog to make checkbox control with properties {static label:"Styles de caractères", checked state:true, min width:45}

                        end tell

                    end tell

                end tell

            end tell

        end tell

    end tell

   

    set myResult to show myDialog

   

    if myResult then

        tell document 1

            set allParagraphStyle to every paragraph style

            set allCharacterStyle to every character style

            if checked state of ParagraphStyleDialog then

                repeat with aParagraphStyle in allParagraphStyle

                    if name of applied font of aParagraphStyle = item ((selected index of SearchFontDialog) + 1) of myFonts then

                        set applied font of aParagraphStyle to item ((selected index of ReplaceFontDialog) + 1) of myInddFonts

                    end if

                end repeat

            end if

           

            if checked state of CharacterStyleDialog then

                set mySearchFont to text items of item ((selected index of SearchFontDialog) + 1) of myFonts

                set myReplaceFont to text items of item ((selected index of ReplaceFontDialog) + 1) of myInddFonts

                repeat with aCharacterStyle in allCharacterStyle

                    if applied font of aCharacterStyle = (item 1 of mySearchFont) and font style of aCharacterStyle = (item 2 of mySearchFont) then

                        set applied font of aCharacterStyle to item 1 of myReplaceFont

                        set font style of aCharacterStyle to item 2 of myReplaceFont

                    end if

                end repeat

            end if

        end tell

    end if

   

    destroy myDialog

end tell

set text item delimiters to myOldTID

Regards

DBLjanAuthorCorrect answer
Legend
April 8, 2014

Well, thank you for your answer, this was helpful and I tried to make it work for me, but I couldnt…then I stumbled upon an other thread, and worked it around to this:

tell application "Adobe InDesign CS5.5"

  activate

          if not (exists active document) then

                    display dialog "Kein Dokument geöffnet." buttons {"Hmpf."} default button 1 with icon 2

          else

                    set user interaction level of script preferences to never interact

  -- Suchabfragen speichern

                    set oldFTP to properties of find text preferences

                    set oldCTP to properties of change text preferences

 

  -- Wechsel

                    set find text preferences to nothing

                    set change text preferences to nothing

 

                    set properties of find text preferences to {applied font:"Futura ND", font style:"Bold"}

                    set properties of change text preferences to {applied font:"JaneAusten", font style:"NoSecret"}

  change text

 

  -- Suchabfragen wiederherstellen

                    set properties of find text preferences to oldFTP

                    set properties of change text preferences to oldCTP

 

                    set user interaction level of script preferences to interact with all

          end if

end tell

Now I can add a whole bunch of converts for every font style. JaneAusten was a obvoius test, but it works.