├── screenshots ├── usage.jpg └── result.jpg ├── README.md └── List Fonts.jsx /screenshots/usage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frontendbeast/list-fonts/HEAD/screenshots/usage.jpg -------------------------------------------------------------------------------- /screenshots/result.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frontendbeast/list-fonts/HEAD/screenshots/result.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #List Fonts 2 | 3 | ![Screenshot of resulting dialog box](/screenshots/result.jpg?raw=true) 4 | 5 | A very basic PhotoShop script to list all fonts used in the currently open and active PSD. The script looks at all text layers, and will also find multiple fonts from the same text layer. The results are shown in a dialog box, the contents of which can be selected, copied and pasted. 6 | 7 | ## Installation 8 | 9 | Save the `List Fonts.jsx` file to your "Applications/Adobe Photoshop [version]/Presets/Scripts" folder. Then open/reopen Photoshop. 10 | 11 | ## Usage 12 | 13 | From the "File" menu, select "Scripts" and then "List Fonts". A dialog box will then appear listing the fonts used in the PSD. 14 | 15 | ## TODO 16 | 17 | * Handle zero results a little nicer 18 | 19 | ## Disclaimer 20 | 21 | Tested on Mac and PC (Win 8.1), running Adobe Photoshop CC 2014. It might not work for you. 22 | 23 | ## Screenshot 24 | 25 | ![Screenshot of menu location](/screenshots/usage.jpg?raw=true) 26 | -------------------------------------------------------------------------------- /List Fonts.jsx: -------------------------------------------------------------------------------- 1 | var refPSD = new ActionReference(); 2 | 3 | function arrayUnique(a){ 4 | var temp = [] 5 | i = a.length; 6 | 7 | // ExtendScript has no indexOf function 8 | while(i--) { 9 | var found = false, 10 | n = temp.length; 11 | 12 | while (n--) { 13 | if(a[i] === temp[n]) { 14 | found = true; 15 | } 16 | } 17 | 18 | if(!found) { 19 | temp.push(a[i]); 20 | } 21 | } 22 | 23 | return temp; 24 | } 25 | 26 | function findFonts() { 27 | refPSD.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); 28 | 29 | // Get layers from PSD 30 | var countLayers = executeActionGet(refPSD).getInteger(charIDToTypeID('NmbL'))+1, 31 | fonts = []; 32 | 33 | // Loop through each layer 34 | while(countLayers--) { 35 | var refLayer = new ActionReference(), 36 | descLayer, 37 | layerStyles, 38 | countStyles; 39 | 40 | refLayer.putIndex( charIDToTypeID( 'Lyr ' ), countLayers ); 41 | 42 | // Catch error when no backgroundLayer is present 43 | try { 44 | descLayer = executeActionGet(refLayer); 45 | } catch (e) { 46 | continue; 47 | } 48 | 49 | // Only proceed if text layer 50 | if(!descLayer.hasKey(stringIDToTypeID( 'textKey' ))) continue; 51 | 52 | // Get list of styles (in case of multiple fonts in a text layer) 53 | layerStyles = descLayer.getObjectValue(stringIDToTypeID('textKey')).getList(stringIDToTypeID('textStyleRange')); 54 | countStyles = layerStyles.count; 55 | 56 | // Loop through each style and get the font name 57 | while(countStyles--) { 58 | try { 59 | var fontName = layerStyles.getObjectValue(countStyles).getObjectValue(stringIDToTypeID('textStyle')).getString(stringIDToTypeID('fontPostScriptName')); 60 | fonts.push(fontName); 61 | } catch (e) { 62 | continue; 63 | } 64 | } 65 | } 66 | 67 | // Return a unique and sorted array of font names 68 | return arrayUnique(fonts).sort(); 69 | } 70 | 71 | if (documents.length) { 72 | var fontsFound = findFonts(); 73 | alert(fontsFound.length +' fonts found \n'+fontsFound.join('\n')); 74 | } else { 75 | alert('No fonts found \nOpen a PSD before running this script',); 76 | } 77 | --------------------------------------------------------------------------------