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

Changing fonts in paragraph and character styles (AppleScript, Grep or JavaScript)

Guest
Apr 29, 2013 Apr 29, 2013

Copy link to clipboard

Copied

I have been trying the javascripts in this discussion:

Adobe Community: Specified font need to be changed in all paragraph styles

but I cannot get any of them to work. I have been putting them into CodeRunner then saving them into the InDesign Scripts folder but I have specific error messages for the ones I have tried. I am wondering if they actually solve my problem anyway, which is:

Helvetica Neue LT seems to add another LT to its description thus: "Helvetica Neue LT LT 45" instead of just "Helvetica Neue LT 45".  InDesign does not recognise this and thus when I open each file I get a list of Fonts to be found. I have dozens of styles (Paragraph and Character) in dozens of files and have changed some of the styles manually - a laborious task. The styles must be changed otherwise I am still stuck with Helvetica Neue LT lurking away, waiting for the style to be applied. So I cannot use "Find font..." in the Type Menu.

I am changing to "Helvetica Neue LT Std" with many faces: 35 Thin, 45 Light, 46 Light Italic, 65 Medium, 75 Bold...

from the similar faces in Helvetica Neue LT. These currently display in the Styles Menu as [Helvetica Neue LT] [LT 45 Light]

Sometimes when I change to Helvetica Neue LT Std manually the face sticks (even though I have changed it) so I have "Helvetical Neue Ltd Std [LT 45 Light]" and I have to go through the styles again and again. This is very tedious.

So if anyone can help me with this problem I'd be eternally grateful.

Using InDesign CS6, MacMini 2012, Mountain Lion (though I had the same problem in Lion)

TOPICS
Scripting

Views

4.1K

Translate

Translate

Report

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
Advisor ,
Apr 29, 2013 Apr 29, 2013

Copy link to clipboard

Copied

Hi James. Just a few threads down the list there is this: http://forums.adobe.com/thread/1198632?tstart=0

Even the name of the thread is similar to yours.

But first, you should do a bit of housecleaning in your font library. From your description it sound like a big mess.

Do you use any font management tools? Most of the times they do more harm than good (but i am aware that it's a necessary evil for the most part).

The fonts you are trying to use are in the font library or in the indesign document's folder?

While Mac is a lot better than Windows in managing multiple fonts/font versions, it's also a lot more "fragile" if something goes wrong with a font.

Try cleaning the font cache first:

sudo atsutil databases -remove

the restart the font server

sudo atsutil server -shutdown

sudo atsutil server -ping

have a look here also:

http://forums.adobe.com/thread/1201617?tstart=0

Votes

Translate

Translate

Report

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
Guest
Apr 30, 2013 Apr 30, 2013

Copy link to clipboard

Copied

Thanks for taking the time to reply, Vamitul.

I have refreshed the font cache using Terminal, as you suggested.

I did try that javascript you cite, but it did not work then, and I have just tried it again and it still doesn't work. 

Here is the script as I used it:

________________________

var myDoc=app.activeDocument;

var pstyles = myDoc.allParagraphStyles;

for (var a=1; a<allStyles.length; a++)

{

    if (pstyles.appliedFont.name.match(/"HelveticaNeue LT"/i){

         pstyles.appliedFont="Helvetica Neue LT Std";

       }

}

__________________________________

I get this error message:

INDD JS error message.png

I have tried moving the { (after the "/i)) to a new line but that doesn't make any difference. Note: I am very unfamiliar with JavaScript. I am much more familiar with AppleScript (but that isn't saying much about my AppleScript abilities).

Votes

Translate

Translate

Report

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
Advisor ,
Apr 30, 2013 Apr 30, 2013

Copy link to clipboard

Copied

you are missing a closing parantheses:

   if (pstyles.appliedFont.name.match(/"HelveticaNeue LT"/i))

{

i hope this will work for you, but like i said, i think the problem is a lot deeper, having to do with conflicts between installed OS fonts, document fonts and the way Indesign works with them (wich for the most part still involves a lot of voodoo and other dark magic). Have you tried working on a different machine?

Votes

Translate

Translate

Report

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
Guest
Apr 30, 2013 Apr 30, 2013

Copy link to clipboard

Copied

I have been working on three different machines. Same problem.

Tried your revised script but I get another error message:

INDD JS error 2.png

Votes

Translate

Translate

Report

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
Advisor ,
Apr 30, 2013 Apr 30, 2013

Copy link to clipboard

Copied

var myDoc=app.activeDocument;

var pstyles = myDoc.allParagraphStyles;

for (var a=1; a<pstyles.length; a++)

{

    if (pstyles.appliedFont.name.match(/"HelveticaNeue LT"/ig)){

         pstyles.appliedFont="Helvetica Neue LT Std";

       }

}

Votes

Translate

Translate

Report

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
Guest
Apr 30, 2013 Apr 30, 2013

Copy link to clipboard

Copied

Have tried your revised script. No error message, but it does not change anything. I checked a couple of paragraph styles. Is the script supposed to work for all styles, or just one? If so, which one and can the script work its way through the paragraph style list?

The font names are of the font family. Should I include the font face name as well? If so, how do I state it, for example  "Helvetica Neue LT LT 45 Light" (which is how InDesign lists it on the "Find Font..." window)?

Have you tested this script on your computer? If so, can you let me know how it worked.

If you are using a PC then the font faces are normally listed as separate entities while on a Mac the font and its various faces is one unit.

Votes

Translate

Translate

Report

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
Advisor ,
Apr 30, 2013 Apr 30, 2013

Copy link to clipboard

Copied

james, you have a private message form me.

Votes

Translate

Translate

Report

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
Engaged ,
Nov 18, 2016 Nov 18, 2016

Copy link to clipboard

Copied

Dear Vamitul,

Can you explain you script, please? I am on learning stage.

What does mean /ig in line 5?

Regards,

Sumit

-Sumit

Votes

Translate

Translate

Report

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
Advisor ,
Nov 18, 2016 Nov 18, 2016

Copy link to clipboard

Copied

Hi Sumit,

Here you can find the all the info:

RegExp - JavaScript | MDN

Votes

Translate

Translate

Report

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
Engaged ,
Nov 18, 2016 Nov 18, 2016

Copy link to clipboard

Copied

LATEST

Thank you Vamitul!

-Sumit

Votes

Translate

Translate

Report

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