InDesign: ExtendScript to list fonts and extended font information -


i need list detailed information fonts used in set of indesign documents. information need accessible through menu item type › find fonts… (as explained here) going through each font in every document , writing down information not feasible.

i can find of information in font objects underdocument.fonts , question how access or generate extended properties found in panel below:

  • character count given font
  • pages font occurs

1

edit: document.fonts array doesn't seem include missing fonts.

well, here's brute-force strategy character counting. iterates through every character textstylerange in document , checks applied font. edit: updated use textstyleranges. faster going through every character.

var document = app.open(new file(folder.desktop.fsname + "/test/test.indd")); try {     var fontmultiset = countcharsinfonts(document);      // each font, display character count.     var fonts = document.fonts.everyitem().getelements();     (var = 0; < fonts.length; i++) {         var fontname = fonts[i].fullname;         $.writeln(fontname + ": " + fontmultiset[fontname]);     } } {     document.close(); }  function countcharsinfonts(document) {     // create font multiset.     var fontmultiset = {         add: function add(fontname, number) {             if (this.hasownproperty(fontname)) {                 this[fontname] += number;             }             else {                 this[fontname] = number;             }         },     };      // every textstylerange in document, add applied font multiset.     var stories = document.stories.everyitem().getelements();     (var = 0; < stories.length; i++) {         var story = stories[i];         var textstyleranges = story.textstyleranges.everyitem().getelements();         (var j = 0; j < textstyleranges.length; j++) {             fontmultiset.add(textstyleranges[j].appliedfont.fullname, textstyleranges[j].length);         }     }      // fonts aren't applied in document, set character count 0.     var fonts = document.fonts.everyitem().getelements();     (var = 0; < fonts.length; i++) {         var fontname = fonts[i].fullname;         if (!fontmultiset.hasownproperty(fontname)) {             fontmultiset[fontname] = 0;         }     }      return fontmultiset; } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -