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

changing text from helvetica to arial with javascript

Explorer ,
Mar 11, 2013 Mar 11, 2013

I’m working with PDF files in illustrator and whenever the file uses Helvetica I have to change the font to Arial. This gets old when working with hundreds of illustrations. Can anyone tell me how I would go about changing all text that uses Helvetica bold to Arial bold and Helvetica Roman to Arial?

Would I loop through all the text frames and get the value of the font and use that value to change them or is there a more global way to go about this?

Any help would be appreciated,

Duane

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

Community Expert , Mar 11, 2013 Mar 11, 2013

DuanesSearchForKnowledge wrote:

… If there was a way to find the font used in the file and select thetext using that font it seems it would be possible to change it to one of these fonts. I dont know enough about it to know if it is possible or not.

Thanks for the info,

Duane

Look at this example:

if (app.documents.length > 0 ) {

    var doc = app.activeDocument;

    var aFont = (doc.textFrames[0].textRange.textFont)

    // You always need the correct internal text font name

    // change to regular, if

...
Translate
Adobe
Community Expert ,
Mar 11, 2013 Mar 11, 2013

You can create an Action to do this and in CS6 run the action by using the doScript construct.

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 ,
Mar 11, 2013 Mar 11, 2013

Intriguing!!!

I am stuck with CS 5 for now. I assume this doScript construct is only available in CS6?

Thanks for the info,

Duane

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
Community Expert ,
Mar 11, 2013 Mar 11, 2013

For ExtendScript, yes. For AppleScript and VBS, no.

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
Guru ,
Mar 11, 2013 Mar 11, 2013

A more global way would be to use the app's 'Find Font' feature…? Im not a user of actions so you could test if it's recordable and you could use with actions and batch…

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
Community Expert ,
Mar 11, 2013 Mar 11, 2013

I tried and it is indeed recordable. You could do it as a two part action and assign it an F-key or use it in a script.

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 ,
Mar 11, 2013 Mar 11, 2013

Thanks for checking.

I did try it and it worked for me but can I use the action in a script with CS 5?

Thanks,

Duane

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
Guru ,
Mar 11, 2013 Mar 11, 2013

Without knowing more of your work flow its hard to say… CS5 can't call action using ESTK the feature is NEW to CS6. An action can call a script ( although its forgetful ). So it can depend on what you are trying to do and where…?

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 ,
Mar 11, 2013 Mar 11, 2013

it doesnt sound like it would be dependable.

what my workflow is;

Script: open a file

Script: unhide all layers

Script: deletes layer named raster

Script: deletes layer named searchable text

Action: change all text to arial and arial bold (This is where I would need the action to work)

script: copys all text to a layer and changes it's color, then hides it .

script: copys everything to a new layer and rasterizes it.

script : hides all layers and then turns on raster layer and searchable text layer.

script: saves and closes file

then repeated over about 600 files.

can't wait to get CS 6!

Thanks for the help,

Duane

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
Community Expert ,
Mar 11, 2013 Mar 11, 2013

then, back to your question, yes you'll have to loop through all text frames...

or, what if you uninstall Helvetica temporarily? then on opening the file you swap the font, just an idea, not sure if it will help much.

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 ,
Mar 11, 2013 Mar 11, 2013

The Find Font is what i use now. I wanted to find a way to do it with ExtendScript quicker. I have found that my arial font I use is textFont[12] and the arial bold I use is textfont[14] on my system. If there was a way to find the font used in the file and select thetext using that font it seems it would be possible to change it to one of these fonts. I dont know enough about it to know if it is possible or not.

Thanks for the info,

Duane

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
Guru ,
Mar 11, 2013 Mar 11, 2013

Selecting the text script or GUI is the slowest method… Find Font will do this globally without trawling every character of every text frame… And it will be plug-in which is far faster than script…

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 ,
Mar 11, 2013 Mar 11, 2013

Do you know if it can be automated in CS 5? part of my script  unhides layers that need the text change.

Thanks for the info,

Duane

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
Community Expert ,
Mar 11, 2013 Mar 11, 2013

DuanesSearchForKnowledge wrote:

… If there was a way to find the font used in the file and select thetext using that font it seems it would be possible to change it to one of these fonts. I dont know enough about it to know if it is possible or not.

Thanks for the info,

Duane

Look at this example:

if (app.documents.length > 0 ) {

    var doc = app.activeDocument;

    var aFont = (doc.textFrames[0].textRange.textFont)

    // You always need the correct internal text font name

    // change to regular, if bold

    if (aFont.name == textFonts.getByName("MyriadPro-Bold").name) { // I haven't Helvetica here, so I take this font instead

        doc.textFrames[0].textRange.textFont = textFonts.getByName("MyriadPro-Regular");

        }

    // try and have fun

}

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 ,
Mar 22, 2013 Mar 22, 2013

Thank you Pixxxel schubser, I was able to selected all my helvetica text and change it to arial in my document.

 

   var doc3 = app.activeDocument;

   var myTextFrame = app.activeDocument.textFrames;

  

        for (i = 0; i < myTextFrame.length; i++) {

                var textArtRange = doc3.textFrames;

                var aFont = (doc3.textFrames.textRange.textFont)

                        if (aFont.name == textFonts.getByName("Helvetica").name) {

                             try {

                             //doc3.textFrames.selected = true; 

                             doc3.textFrames.textRange.textFont = textFonts.getByName("Arial-BoldMT");

                             } catch (e) {}

                        }

        }

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
Community Expert ,
Mar 23, 2013 Mar 23, 2013
LATEST

You're welcome

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