Skip to main content
tpk1982
Legend
January 17, 2017
Answered

Collect used fonts

  • January 17, 2017
  • 1 reply
  • 3104 views

Hello,

Is it possible to collect the used fonts in the active document?

Tried coding:

var  myFonts=app.documents[0].stories.everyItem().textStyleRanges.everyItem().appliedFont;

  len = myFonts.length; 

var  destFolder = "~/Desktop/usedFonts/"; 

if ( !Folder(destFolder).create() ){ exit();  }

while (len-->0) { 

  myfontpath = myFonts[len].filePath; 

  currFile = File( destFolder + File(myfontpath).name ); 

  if ( !currFile.exists && File(currLinkFName).exists ) 

  myfontpath[len].copyLink(currFile); 

  } 

Regards,

K

This topic has been closed for replies.
Correct answer Jump_Over

Hello Peter,

I tried the below coding and it is also not copying the fonts

var  myFonts = app.documents[0].fonts.everyItem().getElements();

len = myFonts.length;   

var  movefolder = "~/Desktop/usedFonts/";     

    for(i=0;i<len;i++){

    movefolder = Folder(movefolder);  

    if (!movefolder.exists) movefolder.create(); 

        if (movefolder.exists){

            myFonts[0].copy(movefolder); 

        }

    }

Thanks,

K


Hi,

Notice that a file is the target - not a font.

var

  myFonts = app.documents[0].fonts.everyItem().getElements(),

  len = myFonts.length,

  cFile, cName, outFile, i,

  movefolder = "~/Desktop/usedFonts/",

  movefolder = Folder(movefolder);  

if (!movefolder.exists) movefolder.create();

for(i=0;i<len;i++) {

  cFile = File(myFonts.location);

  if(!cFile.exists) continue;

  cName = cFile.name;

  outFile = File(movefolder + "/"+ cName);

  cFile.copy(outFile);  

  }

Jarek

1 reply

Peter Kahrel
Community Expert
Community Expert
January 17, 2017

Yes, should be possible. What's the problem with your code?

P.

tpk1982
tpk1982Author
Legend
January 17, 2017

Hi Peter,

Thank you for your reply. The problem is, it is not collecting the fonts as expected.

I am not sure we can take the fonts using filePath, because it will work for images.

var  myFonts=app.documents[0].stories.everyItem().textStyleRanges.everyItem().appliedFont; 

  len = myFonts.length;   

var  destFolder = "~/Desktop/usedFonts/";   

if ( !Folder(destFolder).create() ){ exit();  } 

   

while (len-->0) {   

  myfontpath = myFonts[len].filePath;   

  currFile = File( destFolder + File(myfontpath).name );   

  if ( !currFile.exists)   

  myfontpath[len].copy(currFile);   

  }   

Regards,

K

Community Expert
April 23, 2018

Hi Markus,

thank you for providing the files.

Did some tests.

Document fonts folder is useless in this case. InDesign cannot see the Type-1 fonts there!

The Type 1 fonts must be installed in InDesign's Fonts folder under Applications.

Then the font is available: OS X 10.11.6 German with InDesign CC 2018.1 13.1.0.76.

Regards,
Uwe


A follow up on this:
Used fonts can be packaged with InDesign on OS X 10.11.6.

Strange enough, the fonts will be found and can be used with the packaged InDesign document.

For this test—open the packaged document—I uninstalled the fonts from InDesign's Font folder in Applications and restarted the app.

Maybe I have to redo my first test from my reply above without using subfolders in the Document fonts folder?

Regards,
Uwe