Set Kerning
Copy link to clipboard
Copied
I am trying to set the kerning between chars in Illustrator. Here's my script:
var countDigits=refGrp.textFrames[0].textRange.characters.length;
for(i=0; i < countDigits; i++) {
refGrp.textFrames[0].textRange.characters.characterAttributes.kerning=50;
}
But it doesn't work. refGrp is defined earlier.
Any ideas?
Explore related tutorials & articles
Copy link to clipboard
Copied
You must set the kerningMethod to be on not AutoKernType.NOAUTOKERN for the textRange in order to be able to edit the value.
Sometime ago I spent hours hunting this down, and now it is my gift to you.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Oh that's where I hunted it down!
Copy link to clipboard
Copied
I tried this...
function test()
{
var doc = app.activeDocument;
doc.textFrames[0].textRange.characterAttributes.kerningMethod = AutoKernType.NOAUTOKERN;
var countDigits=doc.textFrames[0].textRange.characters.length;
for(i=0; i < countDigits; i++)
{
doc.textFrames[0].textRange.characters.characterAttributes.kerning=50;
doc.textFrames[0].textRange.characters.characterAttributes.baselineShift=1;
}
}
does nothing to the kerning, but the baselineShift works. Am I doing something wrong?
Copy link to clipboard
Copied
More like this
function test()
{
var doc = app.activeDocument;
doc.textFrames[0].textRange.characterAttributes.kerningMethod = AutoKernType.NOAUTOKERN;
doc.textFrames[0].textRange.kerning=50;
doc.textFrames[0].textRange.baselineShift=1;
}
test ();
Copy link to clipboard
Copied
ok, but if I want to do it char by char?
Copy link to clipboard
Copied
just to add, I have now managed to set the baselineShift and TRACKING char by char, but not the kerning, so I can now control the spacing betwen chars in someway. Maybe this is by design that kerning cannot be done char by char, although it would make more sense the other way round, set tracking on whole string then set kerning char by char.
Copy link to clipboard
Copied
That makes more sense for me.
I think: do not play with a fix value for the kerning!
But it is always the same procedere:
function test()
{
var doc = app.activeDocument;
//doc.textFrames[0].textRange.characterAttributes.kerningMethod = AutoKernType.NOAUTOKERN;
//doc.textFrames[0].characters[1].kerning=50;
doc.textFrames[0].characters[1].tracking=400;
doc.textFrames[0].characters[1].baselineShift=3;
}
test ();
Define what you want to change and ready. In this case (the //kerning) and the tracking and the baselineShift of the second character of the first text frame.
Have fun
Copy link to clipboard
Copied
do you still have problems?

