Copy link to clipboard
Copied
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.
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
...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:
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.
Copy link to clipboard
Copied
Any chance it could work for temporarily installed (document-level) fonts, too?
Copy link to clipboard
Copied
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?
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:
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!!