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

Shifting baseline script?

Explorer ,
Jun 22, 2017 Jun 22, 2017

Good afternoon folks. I'm interested in an Illustrator script which would find all occurrences of the open bracket "(", determine its size, amend its baseline shift to a percentage of its determined size; repeat for its associated closed bracket ")"; loop to the next occurrence. I've checked the Scripting Guides and both 'Baseline' and 'Size' are CharacterAttributes which are amendable. But I don't have the skills necessary to find the font size and incorporate the math needed to calculate the percentage into the javascript. I'm not even sure if that's possible?

Cheers, I hope you're all having a fantastic day : )

Marcrest

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

Valorous Hero , Jun 22, 2017 Jun 22, 2017

Oh but you do sell yourself short!

Well, I don't know about the math you are thinking of, but what I did is visually change my baseline and then set the hard-coded value of (-1) to do my changes.

#target illustrator

function test(){

  var doc = app.activeDocument;

  var t = doc.textFrames[0], thisChar, thisSize, thisBaseline;

  for(var i=0; i<t.characters.length; i++){

    thisChar = t.characters;

    if(thisChar.contents == "(" || thisChar.contents == ")"){

      thisSize =  thisChar.characterAttribute

...
Translate
Adobe
Valorous Hero ,
Jun 22, 2017 Jun 22, 2017

Oh but you do sell yourself short!

Well, I don't know about the math you are thinking of, but what I did is visually change my baseline and then set the hard-coded value of (-1) to do my changes.

#target illustrator

function test(){

  var doc = app.activeDocument;

  var t = doc.textFrames[0], thisChar, thisSize, thisBaseline;

  for(var i=0; i<t.characters.length; i++){

    thisChar = t.characters;

    if(thisChar.contents == "(" || thisChar.contents == ")"){

      thisSize =  thisChar.characterAttributes.size;

      thisBaseline = thisChar.characterAttributes.baselineShift;

      thisChar.characterAttributes.baselineShift = -1;

    }

  };

};

test();

Before:
2017-06-22 16_07_41-Untitled-1_ @ 401% (CMYK_GPU Preview).png

After:

2017-06-22 16_09_40-Untitled-1_ @ 401% (CMYK_GPU Preview).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
Explorer ,
Jun 22, 2017 Jun 22, 2017

@silly-v thank you for your speedy response. You're words about selling myself short are too kind.

I do appreciate what you have scripted and what you have provided as a visual. Thank you. This script is intended for use in a variety of situations and I was vague in my original post regarding the percentage. I have done some testing on the visual effects of shifting the baseline within a range of type sizes which are most likely to be implemented. I have found through this testing that a baseline shift of -8.3% or (-10%) is optimal.

I'm querying the baselineShift value of -1 in your script. What does it represent 1 pt, 1 mm, 1",  or is -1 representative of the value set within Preferences/Type/Baseline Shift within Illustrator? If different operators have this preference set differently it could present a problem during roll-out. If we could incorporate the math it would assuredly be more useful for implementation across multiple machines.

Thank you Silly-V, the world of scripting is a better place with you in it ; )

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 22, 2017 Jun 22, 2017

Oh thank you so much - but I have a long road ahead of me.

The place to look for value's types are in the Object Model Viewer of the ESTK - use the Help menu or Cmd+/ on mac and f1 on the pc.

Open it up, find the CharacterAttributes and see its properties among which you will find:

CharacterAttributes.baselineShift  

Data Type: number

Adobe Illustrator 21 Type Library

The amount of shift (in points) of the text baseline.

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
LEGEND ,
Jan 14, 2019 Jan 14, 2019
LATEST

Silly-V​, this script was just what I was looking for. Thanks for all your contributions to this forum!

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