Recently I was introduced to the hidden "World-Ready composer" in InDesign CS4. It is really nice to see a little of how Adobe is preparing for the future in typesetting complicated, right to left languages etc.

After becoming aware of this new composer, some of the documentation I had previously stumbled across in InDesigns AppleScript library became more obvious, "kashidas", "diacritic position" etc.

An example of Arabic in InDesign CS4.

Arabic text in InDesign CS4

A little searching around the internet, I ended up at Thomas Phinney's fantastic blog, World-Ready Composer in Adobe CS4, where he explains the specifics about what the new composer is for, and why it wasn't officially documented and included in CS4, and gives you a lot of different tools to enable and use these features in InDesign.

The settings

After reading through all the documentation I could find, i have made a short list here, of things that can be applied to text in InDesign CS4 through e.g. AppleScript.

character direction

The direction of the character. Can be default direction, left to right direction or right to left direction.

composer

The text composer to use to compose the text. Can be "Adobe World-Ready Paragraph Composer", "Adobe World-Ready Single-line Composer", "Adobe Paragraph Composer" or "Adobe Single-line Composer".

diacritic position

Position of diacriticical characters. Can be default position, loose position, medium position, tight position or opentype position.

digits type

The digits type. Can be default digits, arabic digits, hindi digits, farsi digits, Native digits, full farsi digits, thai digits, lao digits, devanagari digits, bengali digits, gurmukhi digits, gujarati digits, oriya digits, tamil digits, telugu digits, kannada digits, malayalam digits, tibetan digits, khmer digits or burmese digits.

kashidas

Use of Kashidas for justification. Can be default kashidas or kashidas off.

keyboard direction

The keyboard direction of the character. Can be default direction, left to right direction or right to left direction.

paragraph direction

Paragraph direction. Can be left to right direction or right to left direction.

paragraph justification

Paragraph justification. Can be default justification, arabic justification or naskh justification.

x offset diacritic

The x (horizontal) offset for diacritic adjustment.

y offset diacritic

The y (vertical) offset for diacritic adjustment.

Small activation script

If you would like to play around with this, I have written a small piece of AppleScriptJavaScript that creates a paragraph style with these settings:

  • character direction: right to left direction
  • composer: "Adobe World-Ready Paragraph Composer"
  • digits type: arabic digits
  • paragraph direction: right to left direction
  • paragraph justification: arabic justification
  • kashidas: default kashidas
  • diacritic position: opentype position

The AppleScriptJavaScript can be downloaded here: create_arabic_pstyle.jsx. Modify the script to your needs, the AppleScriptJavaScript syntax should be quite easy to understand.

You can add it to your Scripts palette and run it from there. To do that, place the file inside the "~/Library/Preferences/Adobe InDesign/Version 6.0/Scripts/Scripts Panel" folder.

If you run an InCopy workflow, or you have found this post by searching the web, you probably know the issue with markup up index words in InCopy - the tool is missing.

In the projects where we run an InCopy workflow, it is mainly books, where the editors easily can proofread and correct in the story itself, and letting them mark up index words would be a great in that process as well. I can't see any obvious reason to why Adobe left it out, other than InCopy might be more minded on magazine editing(?), and there isn't much use for indexing in magazines.

The solution

In books where the index are marked up late in the process, after the book is typeset and proofread, we either mark it up ourselves from a printed copy with highlighted words, or we let the editors mark up the index words in InCopy using a colour swatch. When we receive the InCopy story from them, an AppleScriptJavaScript in InDesign takes care of finding all the coloured words and marking them up as index words. When the script is done, a quick search/replace takes care of colouring the words back to their original colour.

The dialog box that asks you which swatch you want to make an index from.

Index from colour

The script might come in handy in other cases as well, but the InCopy case is the most obvious. The same script could be done with character styles as well, but since I'd like to enable marking up that already have a character style applied, I found swatches better suited.

The script

I have uploaded the basic script - letting you select a swatch from a list and it searches the current document, marking up words. You are free to modify it to your needs - might come in handy to convert words to lowercase or things like that.

You can add it to your Scripts palette and run it from there. To do that, place the file inside the "~/Library/Preferences/Adobe InDesign/Version X.0/Scripts/Scripts Panel" folder.

Download index_from_colour.jsx.

As a part of optimizing the AppleScript showed of in my previous post, I talked to a few guys at the Adobe Forums (link), who came up with some great ideas for further testing.

I wrote all my scripting in Apple's Script Editor, where I also executed the script, making it easy to debug problems and issues. But in production, to make the script run faster, adding it to InDesign's Scripts palette and run it from there, made an obvious increase in speed!

From here I was still curious on what easy steps you could do, to make your scripts run even faster. In the forums some suggestions for faster execution came up.

Disable redrawing

Execute the script with Enable Redraw turned off. If this is turned on, you won't be able to see what the application does, since it wont "draw" what it is doing.
The setting can be found in the Scripts palette's options menu.

InDesigns Scripts palette lets you run scripts with redrawing turned off.

Enable Redraw

Delete saved undo steps

InDesign remembers all actions and steps the script does to let you undo them like it normally does when you work with a document. The more actions it has to remember, the slower it runs.

Flush undo's by using "save as"

InDesign flushes its undo memory when a document is saved using "save as". The idea here is to save the document as itself. This can be accomplished using this single line of AppleScript:

Save a document as itself using save to.

save document 1 to (get full name of document 1)

Using CS4's new do script method

The new do script feature let's you execute a script as "one big undo", so InDesign won't remember all the "small actions".

This is the script Olav Kvern wrote for running a script though do script.

--RunScriptFromFile.applescript 
--An InDesign CS4 AppleScript
--
--Runs a script file using the do script method.
set myScriptFile to choose file with prompt "Select an AppleScript"
tell application "Adobe InDesign CS4"
do script myScriptFile language applescript language undo mode fast entire script undo name (myScriptFile as string)
end tell
Run the script without a windowUsing AppleScript you can open a document without a window. Check out this:

Code by Shane Stanley wrote (modified a little), to open a document without a window.

set my_document to choose file with prompt "Select an InDesign document" 
tell application "Adobe InDesign CS4"
set theDocument to open my_document without showing window
-- do your stuff, then open widow with...
tell theDocument to make window
end tell

How much time is saved?

I made a small test document and took time from start to finish. Unfortunately, the tip on opening the document without the window didn't work in this case, since much of the script was based on selecting text etc., which is not possible if no window is open. Here is the timings:

  1. Not flushing undo's with redrawing turned on: 3:08 minutes
  2. Not flushing undo's with redrawing turned off: 1:39 minutes
  3. Using "save as" to flush undo's with redrawing turned on: 3:28 minutes
  4. Using "save as" to flush undo's with redrawing turned off: 1:55 minutes
  5. Using do script to not save undo steps, with redrawing turned on: 3:02 minutes
  6. Using do script to not save undo steps, with redrawing turned off: 1:37 minutes

From these timings I think it is safe to assume that running the script through a do script method is fastest. The difference in this specific case is small, but will only big bigger in larger documents, with more actions to be "remembered" by InDesign. But it also has its cons: since all steps in the script are saved as one single "undo", if an error occurs in the script, you can't fix the error and continue from where it left, but you will have to start over.

If your script handles all errors well, and you are sure that the script won't run into an unexpected errors, I would choose to run the script through a do script, but in this case I would like to be able to continue from where the script left on errors.

The only thing we can fully conclude from this text, is that turning redrawing off will slice the time your script runs almost in two! Which is far better than I expected.