Copy link to clipboard
Copied
hi everyone see in this pic i have set kerning 80 (kerning in thousand of an em) , these are 100 pages of book , where many many places words are like this with different names kerning set, how we can change these kerning value to 100 through find and replace or grep or any other way fastly , i try alot but fail . any help please. thanks in advance.
Copy link to clipboard
Copied
Hi @rehana36276218, I think I have made the script too complex to configure. I have re-written it so that it works differently now. Here's how to use it:
1. Kern a word they way you want it.
2. Select the word.
3. Run script "Kern This Word.js" (see below).
The new script will apply the kerning to all the other instances of that word in your document. Let me know if that approach suits you better.
- Mark
/**
* @file Kern This Word.js
*
* Finds any instance of the selected word and applies kerning to match the selected word's kerning.
*
* Usage:
* 1. Kern a word
* 2. Select that word
* 3. Run script
*
* Tip: add a `settings.searchProperties` object
* to only search for word instances with those
* findGrep properties, eg. `appliedCharacterStyle`.
*
* @author m1b
* @version 2024-08-07
* @discussion https://community.adobe.com/t5/indesign-discussions/advance-kerning/m-p/14777177
*/
function main() {
var settings = {
wholeWords: true,
showResults: true,
searchProperties: null,
};
if (0 === app.documents.length)
return alert('Please open a document and try again.');
var doc = app.activeDocument,
masterWord = doc.selection[0],
counter = 0;
if (!masterWord || 'Word' !== masterWord.constructor.name)
return alert('Please select a single word and try again.');
app.findGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = masterWord.contents;
if (settings.searchProperties)
app.findGrepPreferences.properties = settings.searchProperties;
var words = doc.findGrep(),
len = masterWord.insertionPoints.length;
for (var i = 0, word, len; i < words.length; i++) {
word = words[i];
if (word === masterWord)
continue;
for (var j = 0; j < len; j++) {
if ('Manual' === masterWord.insertionPoints[j].kerningMethod)
word.insertionPoints[j].kerningMethod = 'None';
else
word.insertionPoints[j].kerningMethod = masterWord.insertionPoints[j].kerningMethod;
if (
'Metrics' !== word.insertionPoints[j].kerningMethod
&& 'Optical' !== word.insertionPoints[j].kerningMethod
)
word.insertionPoints[j].kerningValue = masterWord.insertionPoints[j].kerningValue;
}
counter++;
}
if (settings.showResults)
alert('Kerned ' + counter + ' instances of "' + masterWord.contents + '"');
};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Kern Word');
Copy link to clipboard
Copied
hi @m1b code not working on a single word, nothing happened , did you try on my sample file ..? and i want to just select story and apply whole in a document , i want that type of script..
Copy link to clipboard
Copied
Yes I tried on your sample file, but your file is full of pages and pages of various things. I have no idea what you want to kern. Please give me a sample file with only one word, before, and then after the script so I can see what you expect. I don't even understand if you want to use kerning at all, or whether you want the script to add particular space characters in-between letters. I'm sorry but you are not making this easy for me.
Also if you want to simply "open the document" and "run the script", what do you expect the script to do exactly? How do you think the script is going to know what to do? Which words to kern? Where does the desired kerning values come from? This is why there must be a mechanism for configuration—my first script had an object that you could precisely configure to apply kerning to those configured words; for my second script, you must select your kerned word first and then run the script to apply kerning to all other instances of that word.
If you think that it should be enough to just "run the script" without configuration, please tell me why you think that—because I am terribly confused in that case and I might be on the wrong track completely. I think we are having trouble communicating.
- Mark
Copy link to clipboard
Copied
this is the script which am using in script pannel
Copy link to clipboard
Copied
I'd just like to note that after a week, many exchanges and this long detour into a scripted solution, I have absolutely no idea what it is the OP wants to accomplish. Just maybe some clarity on the actual task/process would help focus things, here.
Copy link to clipboard
Copied
Yep! I really thought I knew. But... not so sure anymore.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now