Created
May 25, 2016 17:37
-
-
Save dmjcomdem/0c4bafd9314bad8cb8754b7e52b7530b to your computer and use it in GitHub Desktop.
This file contains 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
var p = new ActionReference(); | |
function arrayUnique(a){ | |
var t = [] | |
i = a.length; | |
while(i--) { | |
var f = false, | |
n = t.length; | |
while (n--) { | |
if(a[i] === t[n]) { | |
f = true; | |
} | |
} | |
if(!f) { | |
t.push(a[i]); | |
} | |
} | |
return t; | |
} | |
function findFonts() { | |
p.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); | |
var c = executeActionGet(p).getInteger(charIDToTypeID('NmbL'))+1, | |
fonts = []; | |
while(c--) { | |
var r = new ActionReference(), | |
descLayer, | |
layerStyles, | |
countStyles; | |
r.putIndex( charIDToTypeID( 'Lyr ' ), c ); | |
try { | |
descLayer = executeActionGet(r); | |
} catch (e) { | |
continue; | |
} | |
if(!descLayer.hasKey(stringIDToTypeID( 'textKey' ))) continue; | |
layerStyles = descLayer.getObjectValue(stringIDToTypeID('textKey')).getList(stringIDToTypeID('textStyleRange')); | |
countStyles = layerStyles.count; | |
while(countStyles--) { | |
var n = layerStyles.getObjectValue(countStyles).getObjectValue(stringIDToTypeID('textStyle')).getString(stringIDToTypeID('fontPostScriptName')); | |
fonts.push(n); | |
} | |
} | |
return arrayUnique(fonts).sort(); | |
} | |
if (documents.length) { | |
var d = findFonts(); | |
alert(d.length +' fonts found\n'+d.join('\n')); | |
} else { | |
alert('No fonts used in the active document.',); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment