Advertisement
Cronos

Illustrator Font List Script

Feb 18th, 2013
3,280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // script.name = fontList.jsx;
  2. // script.description = creates a document and makes a list of all fonts seen by Illustrator;
  3. // script.requirements = none; // runs on CS4 and newer;
  4. // script.parent = CarlosCanto // 02/17/2013;
  5. // script.elegant = false;
  6.  
  7. #target illustrator
  8.  
  9. var edgeSpacing = 10;
  10. var columnSpacing = 195;
  11. var docPreset = new DocumentPreset;
  12. docPreset.width = 800;
  13. docPreset.height = 600;
  14. var idoc = documents.addDocument(DocumentColorSpace.CMYK, docPreset);
  15.  
  16. var x = edgeSpacing;
  17. var yyy = (idoc.height - edgeSpacing);
  18. var fontCount = textFonts.length;
  19. var col = 1;
  20. var ABcount = 1;
  21.  
  22. for(var i=0; i<fontCount; i++) {
  23.     sFontName = textFonts[i].name;
  24.     var itext = idoc.textFrames.add();
  25.     itext.textRange.characterAttributes.size = 12;
  26.     itext.contents = sFontName;
  27.     //$.writeln(yyy);
  28.     itext.top = yyy;
  29.     itext.left = x;
  30.  
  31.     itext.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name);
  32.    
  33.     // check wether the text frame will go off the bottom edge of the document
  34.     if( (yyy-=(itext.height)) <= 20 ) {
  35.         yyy = (idoc.height - edgeSpacing);
  36.         x += columnSpacing;
  37.         col++;
  38.         if (col>4) {
  39.             var ab = idoc.artboards[ABcount-1].artboardRect;
  40.             var abtop = ab[1];
  41.             var ableft = ab[0];
  42.             var abright = ab[2];
  43.             var abbottom = ab[3];
  44.  
  45.             var ntop = abtop;
  46.             var nleft = abright+edgeSpacing;
  47.             var nbottom = abbottom;
  48.             var nright = abright-ableft+nleft;
  49.  
  50.             var abRect = [nleft, ntop, nright, nbottom];
  51.             var newAb = idoc.artboards.add(abRect);
  52.  
  53.             x = nleft+edgeSpacing;
  54.             ABcount++;
  55.             col=1;
  56.        }
  57.     }
  58.     //else yyy-=(itext.height);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement