I'm really no expert in Nastaleeq script.
My first idea is:
Substitute all spaces with two special characters:
1. A DISCRETIONARY_HYPHEN special character where the formatting of this special character should be no fill and no stroke.
2. A ZERO_WIDTH_NONJOINER special character
The formatting could be done with a GREP Style, the substitution with a Search/Replace action or by script.
Optically this could work, but may bear sideeffects, if you export to XML, HTML or EPUB.
//Select a space between two words: var myStory = app.selection.parentStory; var myIndex = app.selection.insertionPoints.index; //Insert two special characters: myStory.insertionPoints[myIndex].contents = SpecialCharacters.DISCRETIONARY_HYPHEN; myStory.insertionPoints[myIndex+1].contents = SpecialCharacters.ZERO_WIDTH_NONJOINER; //Remove the selected space: myStory.characters[myIndex+2].remove(); //Format the DISCRETIONARY HYPHEN: myStory.characters[myIndex].fillColor = "None"; myStory.characters[myIndex].strokeColor = "None";
I tested this script with some Arabic dummy text in InDesign CS6 (German) where I replaced all spaces.
Before/After showing no hidden characters:
Before/After showing all hidden characters:
Used font is Adobe Arabic, language is Arabic.
With that font and the used words (I really have no idea what they are saying, if anything at all) this procedure is pure nonsense, I think
But in your case it may be useful:
Optically there will be no space between the words and hyphenation is still working.
Permanent overset should be prevented through the descretionary hyphen where its fill and stroke is set to none and therefore will be invisible, if hyphenation is done.