11 Replies Latest reply on Oct 19, 2016 8:43 AM by carter the artist

    [JS] Turn ligatures off.

    hmtyrant

      Hi,

      Is there a javascript to turn Ligatures off of Paragraph styles? We have a bunch of files with the ligatures turned on that we need to update. I know you can update the paragraph styles, but I was wondering if there is some way to tell InDesign to turn the Ligatures of with out updating each style.

       

      Thanks!

        • 1. Re: [JS] Turn ligatures off.
          Kasyan Servetsky Level 5

          Here is a simple example which turns ligatures off in all paragraph styles that are not in groups:

           

          var myDoc = app.activeDocument;
          var myParStyles = myDoc.paragraphStyles;
          for (i = 1; i < myParStyles.length; i++) {
              myParStyles[i].ligatures = false;
          }

          • 2. Re: [JS] Turn ligatures off.
            hmtyrant Level 1

            Thank you so much! Will this same script work for removing hyphenation, I just need to change that line in the code?

            • 3. Re: [JS] Turn ligatures off.
              Harbs. Level 6

              All you need to make that work with groups is change: 

              myDoc.paragraphStyles; to: myDoc.allParagraphStyles;

               

              Harbs

              • 4. Re: [JS] Turn ligatures off.
                Harbs. Level 6
                var myDoc = app.activeDocument;
                var myParStyles = myDoc.allParagraphStyles;
                for (i = 1; i < myParStyles.length; i++) {
                    myParStyles[i].ligatures = false;
                    myParStyles[i].hyphenation = false;
                }
                
                • 5. Re: [JS] Turn ligatures off.
                  carter the artist

                  Hello, I know this is a very old thread; but this is exactly what I need. We use a font that has ligatures ruining our readability and it's a corporate font. This means we need to turn off the ligatures constantly (especially when an art director has copy/pasted from Microsoft Word.) We also have a lot of old files that were done by previous art directors and so they never paid much attention to ligatures and sometimes made strange work-arounds because they were nescient of ligatures (for example they would make a space and tighten up the kerning in that space.)

                   

                  Point being is that I really need a script that I can run when I open a file that looks at all text and turns off ligatures and turns off hyphenations regardless if it is part of a group or not. The script you posted looks like what I want, but since Adobe has released a few versions in the past 7 years I think something needs to be changed and outside of some html/css and BASIC about 27 years ago I am not that savvy with coding and scripts.

                   

                  I would appreciate it if you or someone could update this for the current InDesign. Thank you, in advance.

                  • 6. Re: [JS] Turn ligatures off.
                    Kasyan Servetsky Level 5

                    The code still works in the latest version of InDesign -- CC 2015.4.

                    To turn off hyphenations (in all paragraph styles), you have to add one more line of code like so:

                    var myDoc = app.activeDocument;
                    var myParStyles = myDoc.paragraphStyles;
                    for (i = 1; i < myParStyles.length; i++) {
                        myParStyles[i].ligatures = false;
                        myParStyles[i].hyphenation = false;  
                    }
                    

                     

                    ...turns off ligatures and turns off hyphenations regardless if it is part of a group or not.

                    The script processes all paragraph styles irrespective of whether they are in a style group or not.

                     

                    Besides paragraph styles, formatting can be applied  via character styles and as local formatting:

                    Ligatures can be set in the

                    1. paragraph style panel
                    2. character style panel
                    3. character panel

                     

                    hyphenation can be set in the

                    1. paragraph style panel
                    2. paragraph panel

                     

                    So, changing it in a paragraph style will have no effect, if it's overridden by a character styles or local formatting.

                    I think something needs to be changed and outside of some html/css

                    When I was writing this script, I found out that the "export tagging" feature in scripting was buggy. That's why I wasn't able to get it into shape. Though I haven't tested it in the latest version.

                     

                    — Kas

                    • 7. Re: [JS] Turn ligatures off.
                      carter the artist Level 1

                      I tried using this script and got an AppleScript error!
                      Error Number: -2740
                      Error String: A identifier can't go after this identifier
                      .

                       

                      Engine: Default

                      File: {location of the script file.}

                      • 8. Re: [JS] Turn ligatures off.
                        Kasyan Servetsky Level 5

                        This is a JavaScript, not AppleScript.

                        Save it as 'plain text' jsx-file in your Scripts > Scripts Panel folder.

                        • 9. Re: [JS] Turn ligatures off.
                          carter the artist Level 1

                          I saved it as a .scpt originally and I've now tried .js and .jsx and .txt

                           

                          None seem to work....

                          • 10. Re: [JS] Turn ligatures off.
                            Kasyan Servetsky Level 5

                            Download the script from here.

                            • 11. Re: [JS] Turn ligatures off.
                              carter the artist Level 1

                              Thank you very much!!!