Copy link to clipboard
Copied
Hi
I want to give a tracking value of 100 after an opening paranthesis and before closing paranthesis but I want to do this using a script.
I already have a grep query in place for after opening parenthesis: (\x{0028})(?=\S) and replace is empty. Just add tracking value of 100. If its possible to add kerning value, it will be very good.
The grep query for closing parenthesis: (\x{0029})(?=\s) but there the tracking is not working as expected. It is increasing tracking after the closing parenthesis, I want tracking before closing parenthesis.
My first preference would be using kerning. I already have Peter's script in place, which works just fine.
Actually I need this because I want to include it in another script.
I have come up with this :
doc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = '(\x{0028})(?=\S)';
app.changeGrepPreferences.changeTo = "how to add tracking/kerning here";
doc.changeGrep();
How can I include this in a script?
Thanks
Ok, I found the solution.
Here is my final code:
app.findGrepPreferences=app.changeGrepPreferences=null;
app.findGrepPreferences.findWhat="(?<=(\\x{0028}))(?=\\S)";
app.changeGrepPreferences.kerningValue=100;
app.activeDocument.changeGrep();
app.findGrepPreferences=app.changeGrepPreferences=null;
app.findGrepPreferences.findWhat="(?<=\\w)(?=\\x{0029})";
app.changeGrepPreferences.kerningValue=100;
app.activeDocument.changeGrep();
How can I make it better ?
Thanks
Your code works fine, the kerning is applied at the correct places. You could simplify the search strings a bit as follows:
"\\(\\K(?=\\S)"
"\\w(?=\\))"
but your code works as it is.
Copy link to clipboard
Copied
Ok I have comeup with this:
app.findGrepPreferences=app.changeGrepPreferences=null;
app.findGrepPreferences.findWhat="(\\x{0028})(?=\\S)";
app.changeGrepPreferences.tracking=200;
app.activeDocument.changeGrep();
How to solve the space not coming before closing parenthesis ?
Copy link to clipboard
Copied
Ok, I found the solution.
Here is my final code:
app.findGrepPreferences=app.changeGrepPreferences=null;
app.findGrepPreferences.findWhat="(?<=(\\x{0028}))(?=\\S)";
app.changeGrepPreferences.kerningValue=100;
app.activeDocument.changeGrep();
app.findGrepPreferences=app.changeGrepPreferences=null;
app.findGrepPreferences.findWhat="(?<=\\w)(?=\\x{0029})";
app.changeGrepPreferences.kerningValue=100;
app.activeDocument.changeGrep();
How can I make it better ?
Thanks
Copy link to clipboard
Copied
Hi @Bedazzled532 , Specific kerning values need to be applied to an insertionPoint. I can't post any code at the moment, but you should be able to get the insertionPoint after the closed parenthesis and set an amount.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#InsertionPoint.html
Copy link to clipboard
Copied
@rob day Thank you so much Rob
Copy link to clipboard
Copied
Your code works fine, the kerning is applied at the correct places. You could simplify the search strings a bit as follows:
"\\(\\K(?=\\S)"
"\\w(?=\\))"
but your code works as it is.
Copy link to clipboard
Copied
@Peter Kahrel Thank you so much Peter. I really appreciate it.