Skip to main content
Inspiring
August 6, 2014
Question

Change a font using extendscript in illustrator

  • August 6, 2014
  • 1 reply
  • 7100 views

I have a script that loops through text items on an illustrator page and when it encounters one of a certain size it changes it to a different point size. I would also like to alter the font. The code I have is

     if (roundedSize== 7.2) {

                item.textRange.characterAttributes.size=9.6;

                $.writeln(item.textRange.characterAttributes.textFont)

                item.textRange.characterAttributes.textFont="Metric-Semibold"

                };

It work fine without the fourth line, but as soon as I try and set a typeface the loop bails. Could someone tell me what I am doing wrong here

Many thanks

This topic has been closed for replies.

1 reply

pixxxelschubser
Community Expert
Community Expert
August 6, 2014

Hi Bob Haslett,

there are several ways.

One way could be:

item.textRange.characterAttributes.textFont = textFonts.getByName("Metric-Semibold");

Have fun

Inspiring
August 7, 2014

Thanks tha works just as I want it to.