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

Creating quick font sets

Enthusiast ,
Dec 09, 2017 Dec 09, 2017

Copy link to clipboard

Copied

fonts+screens.jpg

I want to create fonts preview sets in InDesign as shown in screenshot. I want to apply all the fonts available in a particular family so that It becomes easy for me to copy and paste such styles in an existing document.

Now, I'm doing the regular "drag, select and apply the font" method. Is there a faster way to apply all the font styles available in a family to text lines?

P.S. I don't know how to create scripts.

TOPICS
Scripting

Views

990

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

correct answers 1 Correct answer

Community Expert , Dec 10, 2017 Dec 10, 2017

Sure there is. You can access the full list of fonts in InDesign through 'app.fonts': https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Application.html#d1e42152

Each single font contains information about its family name (in your case "Akzidenz-Grotesk Std") as well as its styles: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Font.html​

Unfortunately, they are not grouped per family; having the name of one member of a family does not mean you can get a list of all of its sty

...

Votes

Translate

Translate
Community Expert ,
Dec 10, 2017 Dec 10, 2017

Copy link to clipboard

Copied

Sure there is. You can access the full list of fonts in InDesign through 'app.fonts': https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Application.html#d1e42152

Each single font contains information about its family name (in your case "Akzidenz-Grotesk Std") as well as its styles: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Font.html​

Unfortunately, they are not grouped per family; having the name of one member of a family does not mean you can get a list of all of its styles. So you have to write a custom filter to get a list of all styles of the single family. With that list it's just a matter of applying each font to the current 'cursor position' and then writing out the name of the font.

Draw an empty text frame, select any style of the font you're interested in, then run this script:

target = app.selection[0].parentStory;

basefont = app.selection[0].appliedFont.fontFamily;

allfontlist = app.fonts.everyItem().getElements();

fontlist = [];

for (i=0; i<allfontlist.length; i++)

{

  if (allfontlist.fontFamily == basefont)

  fontlist.push(allfontlist);

}

for (i=0; i<fontlist.length; i++)

{

  target.insertionPoints[-1].appliedFont = fontlist;

  target.insertionPoints[-1].contents = fontlist.name.replace('\t',' ')+'\r';

}

to get this:

Screen Shot 2017-12-10 at 3.23.49 PM.png

Note that there is no hidden magic that makes it do things that InDesign itself cannot do either. For example, I have separate fonts called "Arial" and "Arial Black" (as the full family name, not as a separate style). InDesign shows them as separate choices and does not see that the Black is a style of plain "Arial"  because there is no information in the font file that tells it is part of the Arial family.

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
Mentor ,
Dec 10, 2017 Dec 10, 2017

Copy link to clipboard

Copied

Any chance it could work for temporarily installed (document-level) fonts, too?

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
Enthusiast ,
Jun 29, 2018 Jun 29, 2018

Copy link to clipboard

Copied

LATEST

winterm  wrote

Any chance it could work for temporarily installed (document-level) fonts, too?

Yes, I also have this question and also is it possible that we select a bunch of fonts in one go, and we can create a preview set for them using a script?

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
Enthusiast ,
Dec 10, 2017 Dec 10, 2017

Copy link to clipboard

Copied

https://forums.adobe.com/people/%5BJongware%5D  wrote

Sure there is. You can access the full list of fonts in InDesign through 'app.fonts': https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Application.html#d1e42152

Each single font contains information about its family name (in your case "Akzidenz-Grotesk Std") as well as its styles: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Font.html

Unfortunately, they are not grouped per family; having the name of one member of a family does not mean you can get a list of all of its styles. So you have to write a custom filter to get a list of all styles of the single family. With that list it's just a matter of applying each font to the current 'cursor position' and then writing out the name of the font.

Draw an empty text frame, select any style of the font you're interested in, then run this script:

target = app.selection[0].parentStory; basefont = app.selection[0].appliedFont.fontFamily; allfontlist = app.fonts.everyItem().getElements(); fontlist = [];  for (i=0; i<allfontlist.length; i++) {   if (allfontlist.fontFamily == basefont)   fontlist.push(allfontlist); } for (i=0; i<fontlist.length; i++) {   target.insertionPoints[-1].appliedFont = fontlist;   target.insertionPoints[-1].contents = fontlist.name.replace('\t',' ')+'\r'; }

to get this:

Screen Shot 2017-12-10 at 3.23.49 PM.png

Note that there is no hidden magic that makes it do things that InDesign itself cannot do either. For example, I have separate fonts called "Arial" and "Arial Black" (as the full family name, not as a separate style). InDesign shows them as separate choices and does not see that the Black is a style of plain "Arial"  because there is no information in the font file that tells it is part of the Arial family.

Wow!! This is so cool! Thank you so much Jongware!!

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