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

Unable to set kerning value

Guest
Sep 25, 2015 Sep 25, 2015

Hello Guys,

I'm on an script which is setting the kerning value between characters in a textframe.

The following is not working at all (it's giving me error - «the property is not applicable in the current state»)

     newTextFrame.words[0].insertionPoints.kerningValue = 10;

However, i'm not getting error when using the kerningValue property of characters :-

     newTextFrame.characters.kerningValue = 10;

On alert, it's even giving me '10' as set beforehand, but on my indesign document, all kerning values remains (0)

Does anyone have an idea on how to solve this?

Thanking you in advance

TOPICS
Scripting
1.4K
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

correct answers 1 Correct answer

Community Expert , Sep 25, 2015 Sep 25, 2015

What happens if you do this:

newTextFrame.words.everyItem().insertionPoints.everyItem().kerningValue = 10;

Which InDesign version do you use?

Translate
Engaged ,
Sep 25, 2015 Sep 25, 2015

Does the first word actually have f insertion points?

Or do you mean the f-nd insertion point of the frame, as you do with the character?

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
Guest
Sep 25, 2015 Sep 25, 2015

The number of insertion points is 46 actually.  it's running inside a for loop:

for (var f=0; f<newTextFrame.words[0].insertionPoints.length; f++)

{

      alert(newTextFrame.words[0].insertionPoints.kerningValue);

      newTextFrame.words[0].insertionPoints.kerningValue = 10;

     alert(newTextFrame.words[0].insertionPoints.kerningValue);

}


In fact, i'm getting the "property not applicable" error when alerting the kerning value.  When I remove the alerts,  there's no error, but still, no changes in the indesign document,  My final loop is as follows:


    for (var e=0; e<newTextFrame.words.length; e++)

       {

            for (var f=0; f<newTextFrame.words.insertionPoints.length; f++)

            {

                 newTextFrame.words.insertionPoints.kerningValue = 10;

            }

        }


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 ,
Sep 25, 2015 Sep 25, 2015

What happens if you do this:

newTextFrame.words.everyItem().insertionPoints.everyItem().kerningValue = 10;

Which InDesign version do you use?

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
Engaged ,
Sep 25, 2015 Sep 25, 2015

When you start f with 0 you might as well use

     newTextFrame.insertionPoints.everyItem().kerningValue = 10;

if I am not mistaken.

The first insertion point of a word is the one left of the first character.

Otherwise your code works just fine.

Try:

     for (var e=0; e<newTextFrame.words.length; e++) {

            for (var f=0; f<newTextFrame.words.insertionPoints.length; f++) {

                $.write( newTextFrame.words.characters.contents);               

                 newTextFrame.words.insertionPoints.kerningValue = 10;

            }

        }

to check if it is a specific character in your text that does not want to be kerned.

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
Guide ,
Sep 25, 2015 Sep 25, 2015

Hi all,

Kerning regards insertion points between characters, so you'll usually get in trouble when targeting either the first or the last insertion points of a Story. When the kerningMethod is automated (as 'Optical' or 'Metrical') kerning values have a default amount which you can read using myInsertionPoint.kerningValue, but this command fails if the insertion point index is 0 (zero) or the last index in the Story. You then get the "property is not applicable in the current state" error.

Anyway you can override kerning values. Peter has shown how to do this quickly:


myText.insertionPoints.everyItem().kerningValue = 50;

or even


myText.kerningValue = 50; // all underlying insertion points are targeted as well

Interestingly, such command allows to apply the overriding value to both the first and last insertion point (although this has no visual effect). And then myText.insertionPoints[0].kerningValue does not lead to a runtime error and actually returns the value (50).

@+

Marc

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
Guest
Sep 28, 2015 Sep 28, 2015
LATEST

Thnx Guys.  Its working fine now!

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 ,
Sep 25, 2015 Sep 25, 2015

How many insertion points does words[0] have? Fewer than f?

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