Skip to main content
DuanesSearchForKnowledge
Inspiring
June 20, 2015
Question

Changing text and keeping the font style the same

  • June 20, 2015
  • 1 reply
  • 452 views

Using Illustrator cs 5 / JavaScript

I'm having a problem with keeping text styles like bold and Regular(not bold) from change.

here is the problem

say you want to change text like

Scripting is not fun! to Scripting is fun!

no problem...

var docRef = app.activeDocument;

var textRef1 = docRef.textFrames[0];

textRef1.contents = "Scripting is fun!";

but what if that text is like this

Scripting is not fun! (with "Scripting" bold and the rest regular)

when you run the same script it makes all the text bold

Scripting is not fun! = Scripting is fun!

or if "Scripting" is regular and the rest is bold it will turn all of it regular.

Scripting is not fun! = Scripting is fun!


How would we keep the styles from changing?

any help would be appreciated.

This topic has been closed for replies.

1 reply

Qwertyfly___
Brainiac
June 21, 2015

if you are replacing the whole contents with a new string how is it meant to know how to format it.