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

Set Kerning

Community Beginner ,
Jun 24, 2016 Jun 24, 2016

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?

TOPICS
Scripting
797
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
Adobe
Valorous Hero ,
Jun 24, 2016 Jun 24, 2016

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.

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 ,
Jun 24, 2016 Jun 24, 2016
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
Valorous Hero ,
Jun 24, 2016 Jun 24, 2016

Oh that's where I hunted it down!

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 Beginner ,
Jun 25, 2016 Jun 25, 2016

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?

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 ,
Jun 25, 2016 Jun 25, 2016

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

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 Beginner ,
Jun 25, 2016 Jun 25, 2016

ok, but if I want to do it char by char?

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 Beginner ,
Jun 25, 2016 Jun 25, 2016

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.

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 ,
Jun 25, 2016 Jun 25, 2016

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

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 ,
Jun 29, 2016 Jun 29, 2016
LATEST

Dr Tyrell

do you still have problems?

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