Skip to main content
Inspiring
February 16, 2025
Answered

Writing a script to change the font from "xxx1" to "xxx2" for all paragraph styles

  • February 16, 2025
  • 2 replies
  • 1165 views

I am very new to scripts, and I just have a ponctual need.

I have a document using fonts no longer available.

I would like to run a script that will change the definition of all paragraphs using for example the "xxx1" font to "xxx2".

That must be pretty easy, but some help would save me a lot of time learning how to write scripts. I don't know the ExtendScript language.

Thanks.

    Correct answer Klaus Göbel

    Try the following:

    FrameMaker menue -> View - Panel -> Fonts

     

    and then: replace Fonts

    2 replies

    Klaus Göbel
    Klaus GöbelCorrect answer
    Legend
    February 17, 2025

    Try the following:

    FrameMaker menue -> View - Panel -> Fonts

     

    and then: replace Fonts

    Inspiring
    February 18, 2025

    Very nice, thanks!.

    Bob_Niland
    Community Expert
    Community Expert
    February 16, 2025

    If it's just one file, it might be easier to
    save it as .mif,
    open it in a plain text editor (Notepad will do),

    examine some of the font declarations so you know what they look like,
    perform a single CTLh find/change,
    re-save, and
    re-open in FM.

    Inspiring
    February 16, 2025

    Brillant, thanks!

    Bob_Niland
    Community Expert
    Community Expert
    February 16, 2025

    Be sure to keep a copy of the pre-change file.

    It would also be worthwhile to create a short document with the new font, and examine its MIF.

    Font declarations in MIF can look different from the font names in the menus, e.g.
    ‹FPlatformName `W.Source Sans Pro Semibold.R.600'›
    ‹FFamily `Source Sans Pro Semibold'›

     

    And what you need to change may involve more than just the name:
    ‹FWeight `SemiBold'›

     

    For short text strings needing bulk change, there's also a minor risk of unintended changes. Fragments of font tags can appear all over the place. FM files can also contain various binary objects, presented in MIF as somewhat random-appearing blocks of hexadecimal. There is some risk that the string you are changing could semi-randomly appear in a hex object. So when changing:
    ‹FPlatformName `W.Source Code Pro.R.400'›
    to
    ‹FPlatformName `W.Source Serif Pro.R.400'›
    don't just change [Code] to [Serif]. Quote as much of each string as you can.

    ☑ Match Case

     

    Plan B would be to create a small default document (template.fm).
    File🞃Import…Formats
    ☑ Paragraph Formats only
    from the active document (working.fm).
    Revise just the ¶formats of interest in template.fm

     

    Then with the working.fm, and template.fm still open, you can, in working.fm
    File🞃Import…Formats
    of just 
    ☑ Paragraph Formats
    from template.fm