Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

advance Kerning

Contributor ,
Aug 02, 2024 Aug 02, 2024

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. 

 

22.JPG

TOPICS
Bug , EPUB , Experiment , Feature request , How to , Import and export , InCopy workflow , Performance , Print , Publish online , Scripting , SDK , Sync and storage , Type , UXP Scripting
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2024 Aug 07, 2024

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');

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 11, 2024 Aug 11, 2024

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..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2024 Aug 12, 2024

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 06, 2024 Aug 06, 2024

this is the script which am using in script pannel

 

Screenshot 2024-08-07 at 11.12.15 AM.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2024 Aug 12, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2024 Aug 12, 2024
LATEST

Yep! I really thought I knew. But... not so sure anymore. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines