Created
August 20, 2017 23:23
-
-
Save elliotboney/c5110b162f33cfa2ad15621b82bfe146 to your computer and use it in GitHub Desktop.
Creates a doc and lists all fonts seen by illustrator using a string of text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @@@BUILDINFO@@@ fontList.jsx !Version! Wed Jul 27 2016 14:10:20 GMT-0500 | |
| */ | |
| // script.name = fontList.jsx; | |
| // script.description = creates a document and makes a list of all fonts seen by Illustrator; | |
| // script.requirements = none; // runs on CS4 and newer; | |
| // script.parent = CarlosCanto // 02/17/2013; | |
| // script.elegant = false; | |
| #target illustrator | |
| #targetengine main | |
| var edgeSpacing = 10; | |
| var columnSpacing = 195; | |
| var docPreset = new DocumentPreset; | |
| docPreset.width = 800; | |
| docPreset.height = 600; | |
| var idoc = documents.addDocument(DocumentColorSpace.CMYK, docPreset); | |
| var x = edgeSpacing; | |
| var yyy = (idoc.height - edgeSpacing); | |
| var fontCount = textFonts.length; | |
| var col = 1; | |
| var ABcount = 1; | |
| var filterList = [ | |
| "\-Light", | |
| "\-Italic", | |
| "\-Condensed", | |
| "\-Medium", | |
| "\-Bold", | |
| "\-Black", | |
| "\-Book", | |
| "\-Heavy", | |
| "\-UltraLight", | |
| "\-Oblique", | |
| "\-Thin", | |
| "Hebrew", | |
| "Braille", | |
| "Algeria", | |
| "Arabic", | |
| "Hiragino", | |
| "PingFang" | |
| ]; | |
| var content = prompt("Enter Sample Text (or empty for font names)", "", "Font List"); | |
| var prevFontName = ""; | |
| for (var i = 0; i < fontCount; i++) { | |
| var sFontName = textFonts[i].name; | |
| if (new RegExp(filterList.join("|")).test(sFontName)) { | |
| $.writeln('-------> ' + sFontName); | |
| continue; | |
| // At least one match | |
| } | |
| var splitname = sFontName.split('-'); | |
| if (splitname.length ==1 ) { | |
| $.writeln(splitname[0] + ' ('+sFontName+')'); | |
| } else if (splitname[1] !== "Regular" ) { | |
| $.writeln('-------> ' + sFontName); | |
| } else { | |
| $.writeln(sFontName); | |
| } | |
| continue; | |
| var itext = idoc.textFrames.add(); | |
| itext.textRange.characterAttributes.size = 12; | |
| if (content.length > 0) { | |
| itext.contents = content; | |
| } else { | |
| itext.contents = sFontName.replace('-Regular',''); | |
| } | |
| //$.writeln(yyy); | |
| itext.top = yyy; | |
| itext.left = x; | |
| itext.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name); | |
| // check wether the text frame will go off the bottom edge of the document | |
| if ((yyy -= (itext.height)) <= 20) { | |
| yyy = (idoc.height - edgeSpacing); | |
| x += columnSpacing; | |
| col++; | |
| if (col > 4) { | |
| var ab = idoc.artboards[ABcount - 1].artboardRect; | |
| var abtop = ab[1]; | |
| var ableft = ab[0]; | |
| var abright = ab[2]; | |
| var abbottom = ab[3]; | |
| var ntop = abtop; | |
| var nleft = abright + edgeSpacing; | |
| var nbottom = abbottom; | |
| var nright = abright - ableft + nleft; | |
| var abRect = [nleft, ntop, nright, nbottom]; | |
| var newAb = idoc.artboards.add(abRect); | |
| x = nleft + edgeSpacing; | |
| ABcount++; | |
| col = 1; | |
| } | |
| } | |
| //else yyy-=(itext.height); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment