Skip to main content
Known Participant
August 31, 2011
Question

Getting Fonts Used in a PSD

  • August 31, 2011
  • 2 replies
  • 1217 views

I'm trying to script some font swapping in PSDs. It mostly works but I discovered a situation where it breaks. If multiples fonts are used on a single text layer, only the first font is listed. I don't know if there is a workaround for this. I've not found one thus far.

Here's the code I'm using, which I borrowed from a list archive somewhere:

tell application "Adobe Photoshop CS5"

     tell the current document

          set Used_Fonts to {}

          set Text_Layers to every art layer whose kind is text layer

          repeat with This_Layer in Text_Layers

               set This_Font to font of text object of This_Layer

               if This_Font is not in Used_Fonts then

                    set end of Used_Fonts to This_Font

              end if

          end repeat

     end tell

end tell

Used_Fonts

Thanks in advance for any insight into another method to get this info.

Stephan

This topic has been closed for replies.

2 replies

Known Participant
September 6, 2011

Thanks for the suggestions. Turns out I was trying to handle an edge case that doesn't exist in our workflow. The user's file will always have one font per text layer. I'll keep these suggestions for future use if needed.

Thanks again!

Inspiring
August 31, 2011

Does it need to be an Applescript solution?

The only way I know to get a list of fonts used in a single text layer with multiple fonts is by using Action Manager to get the textItem's descriptor and search the textRanges. Applescript can not use Action Manager directly and I can not recall the way to pass the fonts from javascript to Applescript.

I can post a javascript/Action Manager function if it would help.

Inspiring
September 1, 2011

Access is only the first item only… If you use AppleScript you will get NO more Im almost certain the same can be said for JavaScript using the standard DOM… The only way would be to use Action Manager… via do JavaScript… it's been a while but values need to be returned by function or it could write them to file…