Skip to main content
Eshu153
Inspiring
February 23, 2023
Answered

InDesign Italic words issue

  • February 23, 2023
  • 1 reply
  • 1969 views

Hi,

 

I have a manuscript layout in InDesign. It has unfortunately words with starting letter as italic. Is there any way to find out such words using the GREP styles or any other method. There are lot of words. So, it seems impossible to manually look for each of them.

 

Example:

Test

 

Thanks and Regards,

Eswari

This topic has been closed for replies.
Correct answer m1b

Okay. Sorry. I didn't being specific. Its changing the first character to normal. But, the occurrences sometimes, more than one letter in the word.

 

For example,

Test

"Test

"Test

 

These scenario texts are not getting affected. Maybe the code needs some updation.

 

Thanks and Regards,

Eswari


Okay, I'm going to assume that you want to keep the italics if the whole word is italic. So here's a revised script that should work with your test. And screen shots of my test results.

- Mark

/**
 * Removes italics fontStyle in an any word that is not completely italicized.
 * @7111211 m1b
 * discussion https://community.adobe.com/t5/indesign-discussions/indesign-italic-words-issue/m-p/13601388
 */
function main() {

    var findFontStyle = 'Italic',
        changeToFontStyle = 'Regular';

    app.findGrepPreferences = NothingEnum.NOTHING;
    app.changeGrepPreferences = NothingEnum.NOTHING;
    app.findGrepPreferences.findWhat = '[[:punct:]]?\\b[\\l\\u]+';
    app.findGrepPreferences.fontStyle = findFontStyle;

    app.findChangeGrepOptions.includeFootnotes = true;
    app.findChangeGrepOptions.includeHiddenLayers = true;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = true;

    var doc = app.activeDocument,
        found = doc.findGrep(),
        lettersOfWord = /[A-Za-z]+/,
        counter = 0;

    for (var i = 0; i < found.length; i++) {

        var word = found[i].words.item(0);

        if (!word.isValid)
            continue;

        var wordLettersMatch = word.contents.match(lettersOfWord);

        if (wordLettersMatch && wordLettersMatch[0].length > found[i].contents.length) {
            found[i].fontStyle = changeToFontStyle;
            counter++;
        }
    }

    alert('Changed ' + counter + ' partially italicized words.');

} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Un-italicize Partial Words');

1 reply

m1b
Community Expert
Community Expert
February 23, 2023

Hi @Eshu153, I've written a script that might help in your case. It will find italicized first letters (of words longer than one letter) and apply the 2nd character's fontStyle to it. See if that covers your situation.

- Mark

 

/**
 * Removes italics fontStyle in the first character
 * of a word, where the word is longer than one letter
 * and the first character is italicized.
 * discussion https://community.adobe.com/t5/indesign-discussions/indesign-italic-words-issue/m-p/13601388
 */
function main() {

    app.findGrepPreferences = NothingEnum.NOTHING;
    app.changeGrepPreferences = NothingEnum.NOTHING;
    app.findGrepPreferences.findWhat = '\\b[\\l\\u]';
    app.findGrepPreferences.fontStyle = 'Italic';

    app.findChangeGrepOptions.includeFootnotes = true;
    app.findChangeGrepOptions.includeHiddenLayers = true;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = true;

    var doc = app.activeDocument,
        found = doc.findGrep(),
        counter = 0;

    for (var i = 0; i < found.length; i++) {
        var word = found[i].words.item(0),
            nextChar = word.characters.item(1);
        if (
            nextChar.isValid
            && nextChar.fontStyle != 'Italic'
            && word.length > 1
        ) {
            found[i].fontStyle = nextChar.fontStyle;
            counter++;
        }
    }

    alert('Changed ' + counter + ' italicized characters.');

} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Un-italicize First Letters');
Eshu153
Eshu153Author
Inspiring
February 23, 2023

Thanks, Mark.

 

The script throwing error. I saved it as .vbs.

\\b[\\l\\u]

this I tried in GREP find box and could not find any italics.

m1b
Community Expert
Community Expert
February 23, 2023

Hi @Eshu153, please save my script as .jsx (it is ExtendScript, which is a flavour of Javascript).

If you are using Grep in Indesign via the UI, you also need to set the font style:

But please try script first—it will be much easier. 🙂

 

P.S. here is instructions to install a script:

1. Select the text from my post - just the "code" styled part.
2. Make a new text file in Notepad or TextEdit (IMPORTANT: must be plain text—not rich text).
3. Paste the code from step 1.
4. Save as "Script name here.jsx" (note: file extension is ".jsx") to your desktop.
5. In Indesign, open the Script panel, right-click on on User folder and choose "Reveal".
6. Move the file you saved in step 4 to the User folder that should now be visible.
7. Back in Indesign, the script should appear in the User folder of Scripts Panel (see Window menu > Utility).
8. Double click script name to run the script.