Copy link to clipboard
Copied
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
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
...Copy link to clipboard
Copied
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:
After:
Copy link to clipboard
Copied
@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 ; )
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Silly-V, this script was just what I was looking for. Thanks for all your contributions to this forum!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now