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, you could try this script by @Peter Kahrel. It applies custom kerning pairs.
- Mark
Copy link to clipboard
Copied
If you set an override or global value for kerning, it will be applied regardless of what the font data specifies for each character. More importantly, it will override the many kerning pairs defined in most fonts, including, most likely, one for the two letters above.
Start by resetting this style, or all styles, to "Metrics" kerning (the default) and removing all overrides you may have applied. That should eliminate all these gaps, which your global setting has created. Also check the other two settings noted, for each affected style, as they can have similar effects:
Copy link to clipboard
Copied
i want to increase kerning gap between characters , how we can do it in paragraph style . didn't solve my issue. i dont wana eliminate all these gaps ...
Copy link to clipboard
Copied
Do you want to increase the overall spacing of the letters but retain the connections between them? I don't think that can be done with any fixed-glyph font. I don't know if any kind of variable font is available for Arabic, as it would be needed for English italic or handwriting characters.
Fixed fonts are usually created to remain within a kerning limit so that the connections are made and script flow continuous.
Copy link to clipboard
Copied
not resolve my issue please someone look on this challenging job
Copy link to clipboard
Copied
Okay, @rehana36276218 so it sounds like you need something a bit customised. I thought this was an interesting tool to have, so I have written a script that may help you. See if you can follow what it does and how, and let me know if it works in your situation. It is quite configurable via the `kerns` array.
- Mark
/**
* @file Kern Words.js
*
* Finds particular words and sets the kerning of those words explicitly.
*
* Tips:
* - Edit the `kerns` array to suit your words and kerning.
* - The `properties` object can contain any valid `findGrepPreferences`
* properties and values.
*
* Important:
* - The `kerning` values correspond to the words' insertionPoints
* so the first kern value is BEFORE the first letter of the word.
* for example the word 'cat' will have 4 insertionPoints, and the
* kern object might look like this: {word: 'cat', kerning [-5, 6, -30, 8] }
*
* @author m1b
* @version 2024-08-03
* @discussion https://community.adobe.com/t5/indesign-discussions/advance-kerning/m-p/14777177
*/
function main() {
var kerns = [
{
word: 'tight',
kerning: [0, -50, -10, -30, -50, 0],
properties: { appliedCharacterStyle: 'RED' },
},
{
word: 'loose',
kerning: [5, 10, 20, 30, 40, 5],
properties: { appliedParagraphStyle: 'Body' },
},
{
word: 'spaced',
kerning: [100, 100, 100, 100, 100, 100, 100],
properties: { appliedFont: 'Minion Pro Bold Cond' },
},
];
var settings = {
wholeWords: true,
showResults: true,
};
if (0 === app.documents.length)
return alert('Please open a document and try again.');
var doc = app.activeDocument;
for (var i = 0, kern, words, bracket; i < kerns.length; i++) {
kern = kerns[i];
kern.counter = 0;
bracket = settings.wholeWords ? '\\b' : '';
app.findGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = bracket + kern.word + bracket;
if (kern.properties)
app.findGrepPreferences.properties = kern.properties;
words = doc.findGrep();
for (var j = 0, word, len; j < words.length; j++) {
word = words[j];
len = Math.min(word.insertionPoints.length, kern.kerning.length);
word.kerningMethod = 'None';
for (var k = 0; k < len; k++)
word.insertionPoints[k].kerningValue = kern.kerning[k];
kern.counter++;
}
}
if (settings.showResults) {
var results = ['Kern Words'];
for (var i = 0, kern; i < kerns.length; i++)
results.push(kerns[i].word + ' x ' + kerns[i].counter);
alert(results.join('\n'));
}
};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Kern Words');
Copy link to clipboard
Copied
Thanks m1b , i am having this error while execute your given script
Copy link to clipboard
Copied
Hi @rehana36276218, can you please share a small demo .indd document that shows the error? Also share your "kerns" array. When I've got that, I'll be able to fix. - Mark
Edit: Alternatively, you could comment out the line
// app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Kern Words');
and add, on the very next line:
main();
and run it again. It will show a more useful error now. If you do this, please post the error.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks for the sample document @rehana36276218. I tried my script and it worked as expected. Here's my test kerning object:
{
word: 'فَلَقِ',
kerning: [0, -50, 0, 30, 0, 0, 0],
properties: { appliedCharacterStyle: 'font 24 after before table' }
},
This found and kerned x2 words in your sample document. The kerning values were correctly applied to the words, but the kerning actually didn't seem to do anything, but perhaps this is because I do not have the ME version of indesign.
I did not get any errors though, so maybe the problem is one of your kerning objects? Post a copy of that if you can't get it to work. Also try my suggestion in my previous post about disabling the `doScript` call so I can see the actual error you are getting.
- Mark
Copy link to clipboard
Copied
hi, how are you m1b , i was on leave , actually i dont know how to edit the code ...disabling the `doScript` as you mention , how i will run script i dont know about disabling line in the script . please
Copy link to clipboard
Copied
That's okay, there's no hurry for me, and I hope you had a nice leave. You can disable the line by adding two forward-slashes // to the start of the line. See my post earlier about adding "main();" to the very next line.
- Mark
Copy link to clipboard
Copied
Thanks for your reply m1b still am getting an error in the script i attached file where i add lines as per your given instructions , but i am fail to achieve desired results.
Copy link to clipboard
Copied
I am sorry @rehana36276218, I will explain better. You must add "//" to the start of line that begins with "app.doScript ... " (it will be about line 90 to 100).
Then add a new line on the very next line to that line that just says "main();" without the quotes.
- Mark
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Okay because I didn't remember that you don't know any scripting, so I will give you some more information about configuring the script for your usage.
This is the section you need to change:
var kerns = [
{
word: 'فَلَقِ',
kerning: [0, -50, 0, 30, 0, 0],
properties: { appliedCharacterStyle: 'font 24 after before table' }
},
{
word: 'loose',
kerning: [5, 10, 20, 30, 40, 5],
},
{
word: 'spaced',
kerning: [200, 200, 200, 200, 200, 200],
},
];
This is configured so that there are 3 words that the script knows how to kern: فَلَقِ, loose, and spaced. Each kern object looks like this as a minimum:
{
word: 'word',
kerning: [0, -50, 0, 30, 0],
},
You must have the start and close brace { and }, with the ending comma!
You can add as many words as you like by duplicating these "kerns".
- Mark
Copy link to clipboard
Copied
mb1 is it possible to share with me the correct script file , click2link787@gmail.com....? i am still didn't understand more about coding. thanks please
Copy link to clipboard
Copied
i did these @m1b steps but still getting script error . what i do .. ..? please help me to get out this issue
Copy link to clipboard
Copied
Yes, it won't fix the error, but will now reveal the correct error message. Please let me know what error you get, include what line throws the error.
Copy link to clipboard
Copied
hi @m1b this is an error when executing code.. also i insert // as you mention above
You must add "//" to the start of line that begins with "app.doScript ... " (it will be about line 90 to 100).
Copy link to clipboard
Copied
That error means that you saved the script as rich text. Please save it as plain text (with .js extension). If you paste the script into TextEdit, choose
and then save with a ".js" extension.
And then try script again, and tell me what error you see.
- Mark
Copy link to clipboard
Copied
thanks for in touch, i did as you told me , but script is not executing with no error. just double click the script nothing happened
Copy link to clipboard
Copied
Okay that probably just means that it isn't finding any of the configured kerning words. Can you post your `kerns` object. for example:
var kerns = [
{
word: 'فَلَقِ',
kerning: [0, -50, 0, 30, 0, 0],
properties: { appliedCharacterStyle: 'font 24 after before table' }
},
{
word: 'loose',
kerning: [5, 10, 20, 30, 40, 5],
},
{
word: 'spaced',
kerning: [200, 200, 200, 200, 200, 200],
},
];
What does your one look like? Remember, you have to set it up with your own words. If you post it here, I will test on your sample document.
- Mark
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now