Skip to main content
Participating Frequently
April 23, 2014
Question

AS Replace OpenType All Small Caps with Normal Small Caps

  • April 23, 2014
  • 1 reply
  • 673 views

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.

This topic has been closed for replies.

1 reply

April 23, 2014

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.

RickGroffAuthor
Participating Frequently
April 23, 2014

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!

April 23, 2014

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.