Scripts and Illustrator

PixelPusher

Super Moderator
Staff member
I'm not sure how many of you use scripts within Illustrator but if you do I thought I would share one that I modified from Adobe. This script creates a smooth downward scale of any text object. The effect is simple, but one that many people seem to want to do. It will work with any text object.

Text Scaling
Code:
ChangeSize();

function ChangeSize()
{
    selectedItems = selection;
    // check to make sure something is selected.
    if (selectedItems.length == 0)
    {
        alert("Nothing is selected");
        return;
    }

    endIndex = selectedItems.length;

    for (index = 0; index < endIndex; index++)
    {
        pageObject = selectedItems[index];
        pageItemType = pageObject.typename;

            if (pageItemType == "TextFrame")
            {
                // get the paragraphs from the selection.
                theTextRange = pageObject.textRange;
                paraTextRange = theTextRange.paragraphs;
                numParagraphs = paraTextRange.length;

                   for (i = 0 ; i < numParagraphs ; i++)
                   {
                         aParagraph = paraTextRange[i];

                         charTextRange = aParagraph.characters;
                         charCount = charTextRange.length;

                         if (charCount > 1)
                         {
 
                               beginFontSize = 50;
                               endFontSize = Math.round(beginFontSize*0.2);
                               fontChange = Math.round((beginFontSize - endFontSize)/(charCount-2));
                               for (j = 0 ; j < charCount; j++)
                               {
                                      theChar = charTextRange[j];
                                      theChar.size = currentFontSize;*** 
                                      currentFontSize = currentFontSize - fontChange;
                               }
                         }
                   }
             }
      }
}
 
Last edited:

PixelPusher

Super Moderator
Staff member
If anyone knows more about reserved names in AI, let me know. I would love to take this script one step further and have the "beginFontSize" be whatever site the text is set to.

I will have to look around to see if I can find out more.
 
Top