Copy link to clipboard
Copied
Hi
Is there a way to highlight a word with color through character styles when justification alternate words are substituted by Indesign, automatically ?
In the image I have attached two lines. The one which is black in color is normal justificaiton or justification has been disabled in paragraph style.
The second line, red in color is the same text but Justification Alternate (Naskh) has been enabled in Justification section in paragraph style. Indesign automatically substitute the words if it requires.
My question is when Indesign substitutes a word, is there a way to highlight them ? I know that it can be done manually through character styles, but that is a lot of work. GREP, Script or any other method in Indesign ?
Thanks
An additional clarification: you can find all words that have just alt applied, and you can find the width of those words (using horizontal offset, as you did in your script), but that doesn't tell you whether an alternate was in fact used.
Copy link to clipboard
Copied
Script could compare HorizontalOffset of the InsertionPoints before and after the substituted Character - but script would need access to the "original" text.
Copy link to clipboard
Copied
Hello,
Where do you set 'Justification Alternate (Naskh) '
Would you have a sample document that I could look at.
P.
Edited to say:
This looks like it is an attribute added to the text. It would be possible to detect the attribute and highlight from an PlugIn. Or, even better, if the attribute is a style override you could switch on style override highlighter.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@Pickory Sorry forgot to attach image
Copy link to clipboard
Copied
Thank you.
I suspect I am not going to see those extra options in my UK version of InDesign.
Did you try the style override highlighter?
Copy link to clipboard
Copied
Search Google for the trick to enable Far East and Middle East features - on windows it requires small change in the registry.
Copy link to clipboard
Copied
Ok I will try this. Thanks
Copy link to clipboard
Copied
Would it be possible to package a document for testing purposes?
P.
Copy link to clipboard
Copied
@Pickory I am attaching the idml and the font file. You can test on it.
Copy link to clipboard
Copied
Also, I found this article.
https://research.reading.ac.uk/typoarabic/on-arabic-justification-part-2-software-implementations/
But is not helping me...maybe it will help you understand better.
Thanks
Copy link to clipboard
Copied
There is nothing in the scripting DOM to determine if character has been substituted, so, like I've said the first reply - it would be doable only by comparing HorizontalOffset of the InsertionPoints.
Or via plugin but I'm pretty sure it would require a lot more work...
Copy link to clipboard
Copied
@Robert at ID-Tasker @Pickory has found almost most of the words. There are some words wrongly selected in this method but I guess it can be fine tuned. Lets hope for the best.
Thanks
Copy link to clipboard
Copied
Hi,
This is probably not quite what you are looking for.
P.
Copy link to clipboard
Copied
@Pickory Thanks for the effort.
Some of the images in green are ok and some are not. I have marked with Red, the ones which are wrongly selected. Image attached with Red marks.
A little bit of fine tuning and your are finally there ? Have you used a script for some other method ?
I found this :
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ParagraphJustificationOptions.html
But as I am not into scripting, I have no idea how to start and where to start.
Thanks
Copy link to clipboard
Copied
Hello,
Currently I am using a script.
app.findTextPreferences.otfJustificationAlternate
The bad news is that I now suspect the composer is creating these pairings on the fly. If I am right, this will not be detectable by a script. A plugin should be able to detect this behaviour, but it is not a trivial task.
I list the script here, it expects a swatch called green.
//=============
app.findTextPreferences = null;
app.findTextPreferences.otfJustificationAlternate = true;
var found = app.activeDocument.findText ();
//for ( var j = 0; j < found.length; j++ )
found[1].fillColor = "green";
//=======
You might fnd the wrongs are less than the rights, which might make it easier to highlight the text you want to see.
P.
Copy link to clipboard
Copied
Yes, it's "on the fly".
But just searching for this setting - returns texts that are affected?
Copy link to clipboard
Copied
Unfortunatley I do not understand the text / language, so I can not tell if the founds are correct.
The search does return a list of affected texts. This list is probably a hint to the composer that it is allowed to draw the alternatives. So, not all of the founds are relevent, because they have not been drawn in the 'special way'.
P.
Copy link to clipboard
Copied
If something has been returned - then it has been substituted - even if it looks the same as before...
Copy link to clipboard
Copied
Wait a minute - your code is wrong - it should be:
found[j].fillColor
"j" not "1".
Is it a typo when you were copy&pasting it here - or it's how you run it?
Because in this state - it can't work...
Copy link to clipboard
Copied
The pasted code is wrong, in that instant I wanted to see the 2nd found.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
After you change "1"to" j" - it should be pretty straightforward - you need to save info about HorizontalOffset before and after each found text, temporarily turn off this substituting option, compare new HorizontalOffset values, set substituting option back on.
Or you could save info for all of them to an array, turn off the option for the whole text and then compare and then turn it back on.
Copy link to clipboard
Copied
I ran this script but nothing happened.
app.findTextPreferences = null;
app.findTextPreferences.otfJustificationAlternate = true;
var found = app.activeDocument.findText ();
for ( var j = 0; j < found.length; j++ )
found[j].fillColor = "green";
I even selected the text and ran the script again but no change.
Copy link to clipboard
Copied
@Robert at ID-Tasker @Pickory I have written some code to get the offsets but how do I know which word has been applied with jalt
var doc = app.activeDocument;
var myParas = doc.stories.everyItem().paragraphs.everyItem().getElements();
myWords= myParas[0].words;
//alert(myWords[0].otfJustificationAlternate);
alert(myWords[0].horizontalOffset);
alert(myWords[0].endHorizontalOffset);
//alert(myWords[0].paragraphJustification);
//alert(myWords.length);
//alert(myWords[0].hyphenationZone);
//myWords[0].fillColor = "green";