5 Replies Latest reply on Apr 23, 2014 2:48 PM by [Jongware]

    AS Replace OpenType All Small Caps with Normal Small Caps

    RickGroff Level 1

      Forgive me, but AppleScript (and JavaScript for that matter) is confounding me at every turn. This is a very simple thing, but I can't for the life of me find anything online or in documentation to give me even the slightest clue how to code it. There's nothing in the AppleScript dictionary for InDesign CS6 that shows anything for "all small caps".

       

      I want AppleScript code that looks for OpenType All Small Caps and changes it to normal Small Caps.

       

      Period. Simple. But I'm at a loss.

        • 1. Re: AS Replace OpenType All Small Caps with Normal Small Caps
          RobertKyle Level 2

          Not sure how to phrase this in AppleScript, but here's a javascript snippet that might help you get started:

           

          app.findTextPreferences = app.changeTextPreferences = null;

          app.findTextPreferences.capitalization=Capitalization.CAP_TO_SMALL_CAP;

          app.changeTextPreferences.capitalization=Capitalization.SMALL_CAPS;

          app.activeDocument.changeText();

          app.findTextPreferences = app.changeTextPreferences = null;

           

          Note that this will only change the current text. If you have styles that use CAP_TO_SMALL_CAP, that's another problem.

           

          Note also that this is searching the entire document; you may want a different scope.

           

          Something you might try: open the find/change window and set the Find Format, Change Format fields to do what you want. Then use your script editor to ask what the find/change preferences are. The result will be pretty much what you need to include in your code.

          • 2. Re: AS Replace OpenType All Small Caps with Normal Small Caps
            RickGroff Level 1

            Actually, I'm linking to a javascript from the applescript, so I can pop those lines in at the top and it works fine....Except I also need to change what WAS in OpenType All Small Caps to all lowercase as well, so it comes out properly in normal small caps. I think I've run across some javascript code for that elsewhere. I'll google....

             

            Thanks, Robert!

            • 3. Re: AS Replace OpenType All Small Caps with Normal Small Caps
              RobertKyle Level 2

              Off the top of my head, I think you'll have to use app.activeDocument.findText to get an array of text objects using CAP_TO_SMALL_CAP, then loop through that array to make the change to lowercase and SMALL_CAP.

               

              In other words, I don't think you can make the change to lowercase through Find/Change. You'll notice that in the UI, there's no "lowercase" listed. The opposite of all caps is Normal, which means "as it was typed."

               

              But I'm not entirely sure that changing everything to lowercase will then give you the small caps that you want. I'm thinking that small caps means that the first words of sentences and proper nouns still get large caps.

               

              GOD BLESS THE UNITED STATES OF AMERICA

               

              My understanding of small caps is that the G, U, S and A should all be larger than the other characters.

              • 4. Re: AS Replace OpenType All Small Caps with Normal Small Caps
                [Jongware] Most Valuable Participant

                RobertKyle, the behavior you describe is the default for both native (faux) and OpenType-driven small caps. Some fonts, such as Minion Pro, also allow "OpenType All Small Caps"; then both capital and lowercase appear as the same small caps.

                 

                I am not sure what the magic AppleScript wording is, but changing capitalization in JS is done through Text.capitalization: http://jongware.mit.edu/idcs6js/pc_Text.html#capitalization

                • 5. Re: AS Replace OpenType All Small Caps with Normal Small Caps
                  [Jongware] Most Valuable Participant

                  (Ah -- you knew that last bit already ;) (Why doesn't [Edit] work on my iPad?))