Last active
January 4, 2025 07:36
-
-
Save gneutzling/24df7acf2984bdaf5248 to your computer and use it in GitHub Desktop.
Show fonts used in a Photoshop file.
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
// Salvar o script dentro de Photoshop > Presets > Scripts | |
// http://superuser.com/questions/268785/find-all-the-fonts-used-in-a-photoshop-file | |
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 f \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
https://github.com/dcondrey/DetectFontsinPSD