Copy link to clipboard
Copied
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
However, i'm not getting error when using the kerningValue property of characters :-
newTextFrame.characters
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
What happens if you do this:
newTextFrame.words.everyItem().insertionPoints.everyItem().kerningValue = 10;
Which InDesign version do you use?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
newTextFrame.words[0].insertionPoints
alert(newTextFrame.words[0].insertionPoints
}
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
{
newTextFrame.words
}
}
Copy link to clipboard
Copied
What happens if you do this:
newTextFrame.words.everyItem().insertionPoints.everyItem().kerningValue = 10;
Which InDesign version do you use?
Copy link to clipboard
Copied
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
$.write( newTextFrame.words
newTextFrame.words
}
}
to check if it is a specific character in your text that does not want to be kerned.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thnx Guys. Its working fine now!
Copy link to clipboard
Copied
How many insertion points does words[0] have? Fewer than f?